Hello everyone,
Thanks to all for helped in my previous posts.
Today i am developing a new project.In this I am getting problem with ADC input data reading. I am using ADC0 base and sample sequence 1 (SS1) for data reading purpose.whats i am getting the problem is if i apply input to any of the one channel, actually i want to get output particular channel but i am getting the sample output all four channels. Here i am using processor trigger for triggering the ADC.
Please find the below code and suggest me if any wrong in the code.
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include "inc/hw_gpio.h"
#include "inc/hw_ints.h"
#include "inc/hw_adc.h"
#include "inc/hw_types.h"
#include "DriverLib/adc.h"
#include "DriverLib/interrupt.h"
#include "DriverLib/pwm.h"
#include "DriverLib/timer.h"
unsigned int pui32ADC0Value[4];
extern int keypad_rot;
uint32_t ch0,ch1;
void ADC0IntHandler(void);
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
void
Timer1IntHandler(void)
{
TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
data_disp();
}
void
ADC0IntHandler(void)
{
ADCIntClear(ADC0_BASE, 1);
ADCSequenceDataGet(ADC0_BASE, 1, pui32ADC0Value);
ch0= pui32ADC0Value[0];
ch1=pui32ADC0Value[1];
}
int
main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
SysCtlDelay(5000);
SysCtlPeripheralClockGating(true);
IntMasterEnable();
IntPrioritySet(INT_ADC0SS1_TM4C123, 0x00);
IntPrioritySet(INT_TIMER1A, 0x20);
lcd_pripheral_config();
lcdinit();
TimerConfigure(TIMER1_BASE, TIMER_CFG_A_PERIODIC);
TimerLoadSet(TIMER1_BASE, TIMER_A, (4*SysCtlClockGet()));
IntEnable(INT_TIMER1A);
TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
TimerEnable(TIMER1_BASE, TIMER_A);
ADCSequenceDisable(ADC0_BASE, 1);
ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH0);
ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_CH1);
ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_CH2);
ADCSequenceStepConfigure(ADC0_BASE, 1, 3, ADC_CTL_CH13 | ADC_CTL_IE |
ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 1);
ADCProcessorTrigger(ADC0_BASE, 1);
ADCIntEnable(ADC0_BASE, 1);
IntEnable(INT_ADC0SS1);
}
I am developing this code by the reference of tiva examples.
Please suggest me why i am getting outputs in two channel outputs ch0 and ch1 , if i apply the input to any one channel.
Thanks,
Regards,
Srinu.V