Dear all,
I want to use 2 ADCs.The code I am writing is attached. Both the ADC's are reading same. kindly help.
#include <stdint.h> #include <stdbool.h> #include "inc/hw_gpio.h" #include "inc/hw_types.h" #include "inc/hw_memmap.h" #include "driverlib/sysctl.h" #include "driverlib/pin_map.h" #include "driverlib/gpio.h" #include "driverlib/pwm.h" #include "driverlib/adc.h" #include "driverlib/sysctl.h" unsigned long ulPeriod; uint32_t pui32ADC0Value[1],a[1]; double d,x; double v_cos,v_sin,sum,v_cos2,v_cos_act; double Ts,k1,k2; int main(void) { v_cos=0; pui32ADC0Value[0]=1000; SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3|GPIO_PIN_2); ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceStepConfigure(ADC0_BASE, 2, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END); ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END); ADCSequenceEnable(ADC0_BASE, 3); ADCSequenceEnable(ADC0_BASE, 2); ADCIntClear(ADC0_BASE, 3); ADCIntClear(ADC0_BASE, 2); while(1) { ADCProcessorTrigger(ADC0_BASE, 3); while(!ADCIntStatus(ADC0_BASE, 3, false)) { } ADCIntClear(ADC0_BASE, 3); //put breakpoint here ADCSequenceDataGet(ADC0_BASE, 3, pui32ADC0Value); v_sin=(2.0*pui32ADC0Value[0])/4095.0; ADCProcessorTrigger(ADC0_BASE, 2); while(!ADCIntStatus(ADC0_BASE, 2, false)) { } ADCIntClear(ADC0_BASE, 2); ADCSequenceDataGet(ADC0_BASE, 2, a); } }