Hello,
I want to sample two channels one internal temperature sensor and an external POT on Tiva launchpad.I am able to sample both,but while watching in watch expression window both values are same(ADC0Value and result) and both change at same rate when i rub temp mcu or change POT..I don't Know where i am going wrong.Please help,i am posting my code and debug window image below
#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"
int main(void)
{
uint32_t ui32ADC0Value[4];
uint32_t result[0];
volatile uint32_t ui32TempAvg;
volatile uint32_t ui32TempValueC;
volatile uint32_t ui32TempValueF;
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);//enable clock to peripheral GPIOE
ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE,1,3,ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END);
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 1);
ADCSequenceStepConfigure(ADC0_BASE,3,0,ADC_CTL_CH0|ADC_CTL_IE|ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 1);
ADCSequenceEnable(ADC0_BASE, 3);
while(1)
{
ADCIntClear(ADC0_BASE, 1);//Clears sample sequence interrupt source.
ADCIntClear(ADC0_BASE, 3);
ADCProcessorTrigger(ADC0_BASE, 1);//CONFIGURES PROCESSOR TO TRIGGER THE SAMPLE SEQUENCER//This function triggers a processor-initiated sample sequence if the sample sequence trigger
ADCProcessorTrigger(ADC0_BASE, 3);//is configured to ADC_TRIGGER_PROCESSOR.
while(!ADCIntStatus(ADC0_BASE, 1|3, false))
{
}
ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value);
ADCSequenceDataGet(ADC0_BASE, 3, result);
ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] + ui32ADC0Value[3] + 2)/4;
ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096)/10;
ui32TempValueF = ((ui32TempValueC * 9) + 160) / 5;
ADCSequenceDataGet(ADC0_BASE, 3, result);
}
}