Hi Experts ,
currently i am working TIVAC with ADC, i know the ADC is 12bit so we get 0-4098 value but i get 4900,5000, i don't know the reason for this error value, the adc input voltage is 0-3V but why this value is going to greater than 12bit value, i have shared my serial log and code for your reference kindly check and point out the mistake
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/adc.h"
#include "driverlib/rom.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include "inc/hw_ints.h"
#include "inc/hw_nvic.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
void ConfigureUART(void)
{
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
UARTStdioConfig(0, 115200, 16000000);
}
int main(void)
{
int ulADC0Value[4];
volatile unsigned long ulTempAvg;
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
ADCHardwareOversampleConfigure(ADC0_BASE, 64);
ADCSequenceDisable(ADC0_BASE, 1);
SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOE))
{
}
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_ADC0))
{
}
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3 | GPIO_PIN_2);
ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH0 );
ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE,1);
ADCIntClear(ADC0_BASE, 1);
ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PIOSC | ADC_CLOCK_RATE_FULL, 1);
ConfigureUART();
UARTprintf("Hello, world!\n");
while(1)
{
ADCProcessorTrigger(ADC0_BASE, 1);
while(!ADCIntStatus(ADC0_BASE, 1, false))
{
}
ADCIntClear(ADC0_BASE, 1);
ADCSequenceDataGet(ADC0_BASE, 1, ulADC0Value);
ulTempAvg = (ulADC0Value[0] + ulADC0Value[1] + ulADC0Value[2] + ulADC0Value[3]);
UARTprintf("ADC=%d\n",ulTempAvg);
SysCtlDelay(SysCtlClockGet() / 5 / 3);
}