This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TM4C123GH6PM: TM4C123 ADC Issue

Part Number: TM4C123GH6PM

Tool/software: Code Composer Studio

Hello,

I've TM4C123 launchpad to which I want to interface four analog sensors.

The problem is I'm getting the correct value for 3 sensors, but for the fourth sensor I'm not getting any value. It's showing any random value. 

Also if I use the same code by only changing the clock and port pin according to TM4C129 launchpad, I'm getting values for all four sensors. 

The code is shown below:

#include <stdint.h>
#include <stdbool.h>
#include "string.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/adc.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/ustdlib.h"

uint32_t ui32ADC0Value[4];

int
main(void)
{
uint32_t ui32TempValue;
uint32_t ui32SmokeValue;
uint32_t ui32GasValue;
uint32_t ui32UVValue;
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5);

SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);

ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);

ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH3);
ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH2);
ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH1);
ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);

ADCSequenceEnable(ADC0_BASE, 0);

ADCIntClear(ADC0_BASE, 0);

IntMasterEnable();

while(1)
{

ADCProcessorTrigger(ADC0_BASE, 0);

while(!ADCIntStatus(ADC0_BASE, 0, false))
{
}
ADCIntClear(ADC0_BASE, 0);

ADCSequenceDataGet(ADC0_BASE, 0, ui32ADC0Value);

ui32UVValue = ui32ADC0Value[0];
ui32SmokeValue = ui32ADC0Value[1];
ui32GasValue = ui32ADC0Value[2];
ui32TempValue = ui32ADC0Value[3];

}
}

What changes  has to be made to get all four sensors value correctly??

Regards

Praveen