Part Number:MSP430FR2532
Hello,
I have configured the ADC10 on the MSP430FR2532 but when I get an interrupt there is no value on the ADC input as I check each analog port for the sequence. I am putting a voltage on one port and measured with a volt meter but nothing showing up on the ADC conversion. I have the MSP FET connected to the A6/A5/A4 (TDI/TMS/TCK) pins and do not know if this is the problem.
main()
{
...
ADCCTL0 &= ~ADCENC; // Ensure ENC is clear
// 64 Clk cycles, rising edge the auto conv, adc on,
ADCCTL0 = ADCSHT_4 + ADCMSC + ADCON;
// sampnhold src select ADCSC bit, SAMPCON src samp timer, ADCCLK/4, adc clk SMCLK, sequence of channels no repeat
ADCCTL1 = ADCSHS_0 + ADCSHP + ADCDIV_3 + ADCSSEL_2 + ADCCONSEQ_1;
// Clear all ADC12 channel int flags
ADCIV = ADCIV_NONE;
//ADC resolution 10bit
ADCCTL2 = ADCRES_1;
// 000b = {VR+ = AVCC and VR– = AVSS }, set the highest analog input port for sequence reads (A6)
ADCMCTL0 = ADCSREF_0 + ADCINCH_6;
// enable interrupts for the adc
ADCIE |= ADCIE0;
CSCTL1 |= DCORSEL_5; // Set DCO setting - 16MHz
CSCTL2 &= (~FLLD0); // when using DCO from REF0CLK this divides DCO
CSCTL3 = SELMS__REFOCLK;
CSCTL4 = SELA__REFOCLK + SELMS__DCOCLKDIV; // ACLK = REF0CLK (32kHz), SMCLK/MCLK = DCODIV = 16MHz internal
CSCTL5 = DIVM_0 + DIVS_3; // MCLK divider (0) = 12MHz or 16MHz from interna, SMCLK dividers (8) = 1.5MHz or 2MHz internal DCO divided
...
}
void __attribute__((interrupt(ADC_VECTOR))) ADC_ISR(void) //use this declaration with mspgcc compiler
{
unsigned int adc_result = 0;
ADCCTL0 &= ~ADCIFG; // clear interrupt flag
//adc is configured in sequence and an interrupt will be read for each channel converted
//adc will count down from adc channel 6 - 0
if(adc_count == 6){
adc_sample_temp = 0;
adc_sample_temp = ADCMEM0;
adcB3V_sample[adc_pos] = adc_sample_temp;
}
else if(adc_count == 5){
adc_sample_temp = 0;
adc_sample_temp = ADCMEM0;
adcB2V_sample[adc_pos] = adc_sample_temp;
}
else if(adc_count == 4){
adc_sample_temp = 0;
adc_sample_temp = ADCMEM0;
adcB1V_sample[adc_pos] = adc_sample_temp;
}
else{
adc_result = ADCMEM0; //for all other channels not being used, disregard sample
}
if(adc_count == 0){
adc_count = 6; //reset the adc channel count
}
else{
adc_count--; //decrement interrupt count
}
sample_count_adc_seq++; //let main code know sample is complete, 7 sample_count = 1 sample of each channel (A6 - A0)
ADCCTL0 |= ADCENC + ADCSC; //trigger next conversion
}