Electronic – trigger an ADC conversion through TA0 CCTL1 Output in the MSP430, but nothing is happening

adcmsp430

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.

enter image description here

(User Guide pg 867/1021)

enter image description here

(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

Best Answer

Table 6-12 in the datasheet also shows how the ADC trigger input is connected to the timer:

MSP430FR6989 TA0 output

And this makes clear that the "timer output" is the same signal that would be output to a GPIO pin. In other words, this has nothing to do with the interrupt itself, but you have to configure the output mode to generate a rising edge at the desired time. The default output mode (0) never changes the output; you want something like "Toggle" or "Set/Reset", depending on the frequency:

MSP430 timer output modes