Hey all!
I am using ADC on TIVA tm4c123 for taking data from 2 sensor using sequencer 1.But the issue is if I gave data on one analog channel the other channel also gets updated inspite there is no sensor connected on that channel.I am bit confused.Any answers are really appreciated
My code is
_____________***************************************************_______________________________________
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include <string.h>
#include <stdlib.h>
#include "driverlib/systick.h"
#include "inc/hw_nvic.h"
#include "driverlib/adc.h"
//#include "tm4c123gh6pm.h"
#include "buffer.h"
#include "utils/uartstdio.h"
#include "utils/uartstdio.c"
#include "data_n_math.h"
#include "lib_parse.h"
#include "lcd4d_lib.h"
#include "error_misc.h"
#include "Misc_Config.h"
int main()
{
uint32_t pui32ADC0Value[4];
ROM_FPUEnable();
ROM_FPULazyStackingEnable();
// ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);
//SEt CLOCK TO 80MHZ
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ|SYSCTL_SYSDIV_2_5);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); //ADC0 on
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_1);
//ADC0 sequencer 1 stepconfiguration meaning which fifo to which input chanel
ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);//ADC0 sequencer 1 with 4 fifo so it can sample 4 inputs from 4 different chanels
ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH1);//(ADC),Sequencer1,fifo0,ADC chanel 1(PE2)
ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_CH2| ADC_CTL_IE |ADC_CTL_END);
//ADCHardwareOversampleConfigure(ADC0_BASE,64);
ADCSequenceEnable(ADC0_BASE, 1);
ADCIntClear(ADC0_BASE, 1);
while(1)
{
ADCProcessorTrigger(ADC0_BASE, 1);
while(!ADCIntStatus(ADC0_BASE, 1, false))
{
}
ADCIntClear(ADC0_BASE, 1);
ADCSequenceDataGet(ADC0_BASE, 1, pui32ADC0Value)
}
}