Hi, It 's me again.
I am trying to read ADC value on TIVA. The value displayed in VOM is 3V, but ADC on TIVA returned 3731, which means 3731 * (3/4096)=2.7 V.
I have tried with ADC0 and ADC1 too, but it still displays wrong value.
Here is my simple code:
#include <stdint.h> #include <stdbool.h> #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/sysctl.h" #include "driverlib/adc.h" #include "driverlib/timer.h" #include "driverlib/gpio.h" volatile uint32_t ui32Avg; int main(void) { uint32_t ui32ADC0Value[4]; SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0); ADCSequenceConfigure(ADC1_BASE, 1, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceStepConfigure(ADC1_BASE, 1, 0, ADC_CTL_CH3); ADCSequenceStepConfigure(ADC1_BASE, 1, 1, ADC_CTL_CH3); ADCSequenceStepConfigure(ADC1_BASE, 1, 2, ADC_CTL_CH3); ADCSequenceStepConfigure(ADC1_BASE, 1, 3, ADC_CTL_CH3|ADC_CTL_IE|ADC_CTL_END); ADCSequenceEnable(ADC1_BASE, 1); //TimerLoadSet(TIMER0_BASE, TIMER_BOTH,1000); //TimerControlTrigger(TIMER0_BASE, TIMER_BOTH,true); //TimerEnable(TIMER0_BASE, TIMER_BOTH); while(1) { ADCIntClear(ADC1_BASE, 1); ADCProcessorTrigger(ADC1_BASE, 1); while(!ADCIntStatus(ADC1_BASE, 1, false)) {} ADCSequenceDataGet(ADC1_BASE, 1, ui32ADC0Value); ui32Avg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] + ui32ADC0Value[3])/4; } }