Hello,
I am trying to read 4 ADC channels from A0 to A3 out of 32 ADC channels. I want it to work in Sequence-of-channels (Autoscan) mode.
For the configuration, I followed the below steps:
ADC12CTL0 |= ADC12SHT0_0 | ADC12SHT1_0; // Set sampling time
ADC12CTL1 |= ADC12CONSEQ_1; // Sequence of channels, single conversion mode
ADC12CTL1 |= ADC12SSEL_3; // Select SMCLK clock
ADC12CTL1 |= ADC12SHP; // Use sampling timer
ADC12CTL2 &= ~(3 << 4); // Reset ADC resolution settings
ADC12CTL2 |= ADC12RES_2; // Selecting 12-bit resolution
ADC12MCTL0 |= ADC12INCH_0; // Select ADC input channel A0
ADC12MCTL1 |= ADC12INCH_1; // Select ADC input channel A1
ADC12MCTL2 |= ADC12INCH_2; // Select ADC input channel A2
ADC12MCTL3 |= ADC12INCH_3; // Select ADC input channel A3
For the logic, I followed the below steps:
ADC12CTL0 |= ADC12ON; // Turn ON ADC
ADC12CTL0 |= ADC12ENC; // Enable ADC
ADC12CTL0 |= ADC12SC; // Start conversion-software trigger
while(ADC12CTL1 & ADC12BUSY); // Poll for ADC Busy status
for(index = 0 ; index < 4 ; index++){
ADCvar[index] = ADC12MEM++; // Store the converted value to an array
}
Q1- When the code was checked in debug mode, it was found that, the ADC12BUSY always remains high. And as a result, it is stuck in the while loop.
Is there anything wrong with the ADC configuration?
Please note: the ADC12ENC and ADC12SC bits are set with separate instructions, with internal trigger.
Q2- The values are all stored in ADC12MEM0 only. Should the user increment the register ADC12CSTARTADDx in ADC12CTL3?
I expected it to increment automatically by the processor once the conversion starts. Is that not the function?
Thank you,
Padmini