I am doing a simple project with MSP430FR6989, where I am converting an analog signal to a digital one, when it finishes conversion it will jump to an ISR and increment an integer.
We can configure the ADC12_B (ADC module for the microcontroller) to start sampling and converting by setting ADC12SC bit from ADC12CTL0 register, or through various device-specific triggers.
(User Guide pg 867/1021)
(Datasheet pg 91/183)
I am configuring my MSP430 to start converting using the TA0 CCR1 Output trigger (ADC12SHSx = 001)
With the information I have, I figured that if the CCIF bit of TA0CCTL1 register got set, it will trigger an ADC conversion, and when the conversion is finished and stored in the ADC buffer, an interrupt service routine will be triggered
I have written my code according to the information I have, build the project, and debug it, but during my debugging session my MSP430 never jumps to my ISR routine.
Can someone help me with that issue
This is a sample of the code I have written:
inside the main()
function:
int main (void)
{
//code
init_Timer ();
//configures TA0 CCR1 to 50 ms
init_ADC ();
//ADC12SHSx = 001 (Trigger is TA0 CCR1)
//ADC12IER0 = ADC12IE0; enables ADC12 Interrupt
ADC12CTL0 = ADC12CTL0 | ADC12ENC; //enable Conversion
_BIS_SR(GIE);//enable global interrupt
//rest of code
}
inside the ISR function
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR (void)
{
static int x = 0;
++x;
}
EDIT_0
inside the init_ADC ()
function
void init_ADC (void)
{
ADC12CTL0 = ADC12ON | ADC12SHT0_2;
//ADC ON, 16 ADC12CLK
ADC12CTL1 = ADC12SHS_1 | ADC12SHP | ADC12SSEL_1;
//TA0 CCR1 Output, SAMPCON from Sample Timer, ACLK
ADC12CTL2 = ADC12RES__12BIT;//12 bit resolution
ADC12MCTL0 = ADC12INCH_10;//A10 P9.2
ADC12IER0 = ADC12IE0;//enable MEM0 interrupt (if it's value changed)
ADC12IFGR0 = ADC12IFGR0 & (~ADC12IFG0);
}
Inside init_Timer ()
function
void init_Timer (void)
{
TA0CTL = MC__UP | TASSEL__ACLK;//counts to TA0CCR0, and source from ACLK
TA0CCR0 = 1667;//50 ms count = 50/.03 (Tperiod of ACLK = .03)
TA0CCR1 = 1667;// 50 ms
}
END of EDIT_0