Hi,
I am using an ADC sequencer to monitor 7 power supply voltages on my board.
This is the code that initialises the ADC and its sequencer.
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_ADC0))); //wait for peripheral ready
MAP_GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_0); //1V
MAP_GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_1); //1.2V
MAP_GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_2); //1.5V
MAP_GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_3); //1.8V
MAP_GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_4); //2.5V
MAP_GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_5); //3.3V via div2 resistors
MAP_GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_6); //5V via div2 resistors
ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PIOSC | ADC_CLOCK_RATE_FULL, 1); //clock for both adcs
ADCReferenceSet(ADC0_BASE, ADC_REF_INT); //VDDA = 3.3V
ADCSequenceDisable(ADC0_BASE, 0); //disable sequence before we change it
ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0); //select processor (software) trigger
ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH15);
ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH14);
ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH13);
ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_CH12);
ADCSequenceStepConfigure(ADC0_BASE, 0, 4, ADC_CTL_CH7);
ADCSequenceStepConfigure(ADC0_BASE, 0, 5, ADC_CTL_CH6);
ADCSequenceStepConfigure(ADC0_BASE, 0, 6, ADC_CTL_CH5);
ADCSequenceStepConfigure(ADC0_BASE, 0, 7, ADC_CTL_CH5 | ADC_CTL_END);
ADCIntClear(ADC0_BASE, 0); //clear the interrupt status flag
ADCSequenceEnable(ADC0_BASE, 0); //enable sequence
The sequencer is triggered in the application once a second like this...
uint32_t ADC0_raw[8];
ADCProcessorTrigger(ADC0_BASE, 0); //trigger
while(ADCIntStatus(ADC0_BASE, 0, false)) //wait complete
{
}
ADCIntClear(ADC0_BASE, 0); //clear the ADC interrupt flag
ADCSequenceDataGet(ADC0_BASE, 0, ADC0_raw); //read ADC values
Most of the time this works very well.
However occasionally the sequence gets the channels wrong and channel 0 gets channel 1 input, channel 1 gets channel 2 etc. I can see this happening in the debugger. Once it is in this state it stays this way until reset (I think). This of course renders the supply monitoring totally useless!
Has anyone come across this problem and is there a fix or workaround?
Thanks,
Richard