Hi All,
I checked several resources and looked on the forum but could not find any substantial solution for my problem. I have 2 sensors and these are on PE2 and PE1. I am trying to read from both of them at the same time with ADC. But I get the same value for both of them. Not sure what I am doing wrong below.
Thanks in advance.
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_1);
ADCSequenceConfigure(ADC1_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceConfigure(ADC1_BASE, 1, ADC_TRIGGER_PROCESSOR, 1);
ADCSequenceStepConfigure(ADC1_BASE, 0, 0, ADC_CTL_CH2); //PE2->AIN1
ADCSequenceStepConfigure(ADC1_BASE, 0, 1, ADC_CTL_CH2);
ADCSequenceStepConfigure(ADC1_BASE, 0, 2, ADC_CTL_CH2);
ADCSequenceStepConfigure(ADC1_BASE, 0, 3,
ADC_CTL_CH2 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceStepConfigure(ADC1_BASE, 1, 0, ADC_CTL_CH1); //PE1->AIN2
ADCSequenceStepConfigure(ADC1_BASE, 1, 1, ADC_CTL_CH1);
ADCSequenceStepConfigure(ADC1_BASE, 1, 2, ADC_CTL_CH1);
ADCSequenceStepConfigure(ADC1_BASE, 1, 3,
ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC1_BASE, 0);
ADCSequenceEnable(ADC1_BASE, 1);
ADCIntClear(ADC1_BASE, 0);
ADCIntClear(ADC1_BASE, 1);
ADCProcessorTrigger(ADC1_BASE, 0);
while (!ADCIntStatus(ADC1_BASE, 0, false))
{
}
ADCIntClear(ADC1_BASE, 0);
ADCSequenceDataGet(ADC1_BASE, 0, &reading1);
ADCProcessorTrigger(ADC1_BASE, 1);
while (!ADCIntStatus(ADC1_BASE, 1, false))
{
}
ADCIntClear(ADC1_BASE, 1);
ADCSequenceDataGet(ADC1_BASE, 1, &reading2);