/* Arrays to store SD24 conversion results */
/* NOTE: arrays need to be global to */
/* prevent removal by compiler */
unsigned int results[Num_of_Results];
void main(void)
{
volatile unsigned int i; // Use volatile to prevent removal
// by compiler optimization
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
SD24CTL = SD24REFON + SD24SSEL0; // 1.2V ref, SMCLK
SD24INCTL2 |= SD24INTDLY0; // Interrupt on 3rd sample
SD24CCTL2 |= SD24IE ; // Enable interrupt
for (i = 0; i < 0x3600; i++); // Delay for 1.2V ref startup
SD24CCTL2 |= SD24SC; // Set bit to start conversion
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupts
}
#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
results[index] = SD24MEM2; // Save CH2 results (clears IFG)
if (++index == Num_of_Results)
{
index = 0; // SET BREAKPOINT HERE
}
break;
}
}
#include <msp430afe253.h>
#define Num_of_Results 8
/* Arrays to store SD24 conversion results */
/* NOTE: arrays need to be global to */
/* prevent removal by compiler */
unsigned int results[Num_of_Results];
void main(void)
{
volatile unsigned int i; // Use volatile to prevent removal
// by compiler optimization
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
SD24CTL = SD24REFON + SD24SSEL0; // 1.2V ref, SMCLK
SD24INCTL2 |= SD24INTDLY0; // Interrupt on 3rd sample
SD24CCTL2 |= SD24IE ; // Enable interrupt
for (i = 0; i < 0x3600; i++); // Delay for 1.2V ref startup
SD24CCTL2 |= SD24SC; // Set bit to start conversion
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupts
}
#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
results[index] = SD24MEM2; // Save CH2 results (clears IFG)
if (++index == Num_of_Results)
{
index = 0; // SET BREAKPOINT HERE
}
break;
}
}
一周热门 更多>