Other Parts Discussed in Thread: SEGGER
Tool/software:
I have been facing an issue with ADC channel 11 on the tm4c12433 MCU. I am consistently reading a raw value (step count) of 890, even when no voltage is applied. Ideally, it should read zero as a raw value.
Here are the details:
- **MCU:** tm4c12433
- **Crystal Oscillator (Xtal):** 6 MHz
I have ensured that the pins are correctly enabled as ADC. Below is the configuration I am using to read from ADC channel 11:
#define VBUS_MEAS_ADC_BASE GPIO_PORTB_BASE
#define VBUS_MEAS_ADC_PIN GPIO_PIN_5
GPIOPinTypeADC(VBUS_MEAS_ADC_BASE, VBUS_MEAS_ADC_PIN);
GPIOPinTypeGPIOInput(VBUS_MEAS_ADC_BASE, VBUS_MEAS_ADC_PIN);
uint32_t uiReadVbusVoltage(void)
{
uint32_t ADCValues[1];
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH11 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 3);
ADCIntClear(ADC0_BASE, 3);
while(1)
{
//
// Trigger the ADC conversion.
//
ADCProcessorTrigger(ADC0_BASE, 3);
//
// Wait for conversion to be completed.
//
while(!ADCIntStatus(ADC0_BASE, 3, false))
{
}
//
// Clear the ADC interrupt flag.
//
ADCIntClear(ADC0_BASE, 3);
//
// Read ADC Value.
//
ADCSequenceDataGet(ADC0_BASE, 3, ADCValues);
SEGGER_RTT_printf(0, "Raw sample (ADCValues[0]): %04d\r", ADCValues[0]);
//
// This function provides a means of generating a constant length
// delay. The function delay (in cycles) = 3 * parameter. Delay
// 250ms arbitrarily.
//
SysCtlDelay(80000000 / 12);
}
}
The Output is printed as below:
Raw sample (ADCValues[0]): 0891
Could you please help me identify what might be causing this issue?