Tool/software: Code Composer Studio
Hii
I have written the code to read the different adc channel.
connection for chanel 0 and channel 1
PE3-AIN0----connected to external voltage
PE2-AIN1----shorted with launchpad GND
External voltage ground is shorted with launchapd GND
Whatever the voltage i am applying on AIN0 I am getting the same voltage but when I am doing the same connection on channel 2 and channel 3 then its not working
PE1-AIN2----connected to external voltage
PE0-AIN3----shorted with launchpad GND
Below code I have tried once go through it and let me know if I am doing any wrong
void DifferentialADCInit()
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_6 | GPIO_PIN_7);
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH2 | ADC_CTL_D | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 3);
}
void DifferentialADCRead()
{
ADCIntClear(ADC0_BASE,3);
ADCProcessorTrigger(ADC0_BASE,3);
while(!ADCIntStatus(ADC0_BASE, 3,false));
ADCSequenceDataGet(ADC0_BASE, 3,Diff_Read);
diff_out1 = ((Diff_Read[0]-2048)*3.3)/2048.0;
}
int main(void)
{
ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
DifferentialADCInit();
while(1)
{
DifferentialADCRead();
SysCtlDelay(4000000);
}
}