我使用仿真器调试下面程序时进入中断很慢,而且需要按下全速运行后再按停止,反复几次后才能进到SD24的中断里面,不知什么原因,请大神指教。
#include "msp430afe253.h"
#define Num_of_Results 8
/* Arrays to store SD24 conversion results */
unsigned int Ch0results[Num_of_Results];
unsigned int Ch1results[Num_of_Results];
unsigned int Ch2results[Num_of_Results];
void main(void)
{
volatile unsigned int i; // Use volatile to prevent removal
// by compiler optimization
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= BIT0+BIT1; // Set P1.0, P1.1 to output
SD24CTL = SD24REFON + SD24SSEL0; // 1.2V ref, SMCLK
SD24CCTL0 |= SD24GRP+SD24DF; // Group with CH1
SD24CCTL1 |= SD24GRP+SD24DF; // Group with CH2
SD24CCTL2 |= SD24IE+SD24DF; // Enable interrupt
for (i = 0; i < 0x3600; i++); // Delay for 1.2V ref startup
SD24CCTL2 |= SD24SC; // Set bit to start conversion
__bis_SR_register(GIE); // Enter LPM0 w/ interrupts
while(1);
}
#pragma vector=SD24_VECTOR
__interrupt void SD24AISR(void)
{
static unsigned int index = 0;
switch (SD24IV)
{
case 2: // SD24MEM Overflow
break;
case 4: // SD24MEM0 IFG
break;
case 6: // SD24MEM1 IFG
break;
case 8: // SD24MEM2 IFG
Ch0results[index] = SD24MEM0; // Save CH0 results (clears IFG)
Ch1results[index] = SD24MEM1; // Save CH1 results (clears IFG)
Ch2results[index] = SD24MEM2; // Save CH2 results (clears IFG)
P1OUT ^=BIT0;
if (++index == Num_of_Results)
{
index = 0; // SET BREAKPOINT HERE
P1OUT ^=BIT1;
}
break;
}
}
我用的是MSP430AFE253,用SBW接口传输。谢谢了。
为什么要添加这个延时 for (i = 0; i < 0x3600; i++); // Delay for 1.2V ref startup你把这个去掉看看,我用的是F149的型号,这个地方不需要延时。
回复 沙发 ly971021598 的帖子
谢谢帮助,不是那个地方的问题,是我SD24的时钟设置有问题。它默认的和我选择的不一样。呵呵,很感谢。