Hello,
I am having trouble getting the ADC10 interrupt for the msp430f5510 to trigger. Once I call the function lectura_ADC, to read a value from channel 0, the CPU doesn't "wake up" since the interrupt doesn't get triggered, and consequently I can't get a safe value from the ADC.
Code below...
#include <stdint.h>
#include <msp430.h>
#include <stdlib.h>
#include <Timer.h>
void init_adc10(void)
{
P6SEL |= BIT0 | BIT1;
ADC10CTL0 = ADC10SHT_12 | ADC10ON | ADC10IE | ADC10SREF0 | ADC10SC;
ADC10CTL1 |= ADC10SSEL_0 + ADC10SHP;
ADC10CTL2 |= ADC10RES;
}
unsigned int lectura_ADC(int canal){
unsigned int conv = 0;
ADC10CTL0 &= ~ADC10ENC;
ADC10MCTL0 = ADC10INCH0;
delay_ms(10);
ADC10CTL0 |= ADC10ENC | ADC10SC ;
__bis_SR_register(CPUOFF + GIE);
conv = ADC10MEM0;
delay_ms(10);
return conv;
}
#pragma vector = ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
__bic_SR_register_on_exit(CPUOFF);
}