This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

msp430g2452 ADC interrupt not working

Other Parts Discussed in Thread: MSP430G2452, MSP430WARE

Hi,

I am having a problem with my code, I simply want to set a flag to ensure that the ADC interrupt is working but it doesn't seem to be working.

Here is my code...

#include <msp430g2452.h>


void initAdc();

volatile char flag = 0;

int main(void) {


    WDTCTL = WDTPW | WDTHOLD;    // Stop watchdog timer
    P1DIR |= BIT6;
    P1OUT &= ~BIT6;
    initAdc();
    __bis_SR_register(GIE);


    while(1){

        if(flag == 1){
            P1OUT |= BIT6;
        }else{
            P1OUT &= ~BIT6;
        }
    }
    return 0;
}

void initAdc(){
    
    ADC10CTL1 = CONSEQ_2 + ADC10DIV_3;        //Channel A0 for conversion, ADC10OSC clock used for sampling, repeat single channel
    ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE + ADC10SC + ENC;    //sample and hold time every 16 clocks, Multiple sample conversion, turn on ADC, enable interrupts for ADC, every 16 clock cycles take a sample
    ADC10DTC1 |= 0x01;    //Number of transers in each block
    ADC10AE0 |= 0x01;    //Enables the corresponding pins for analog inputs

}

#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void) {

    flag = 1;

}

**Attention** This is a public forum