Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

ADC more than 1 channel not working (RDK IDM)

$
0
0

Hello

I am working with RDK IDM . I got success in displaying data that sensed by sensor with CH0. Now I stuck at getting data from 2 different sensors with CH0 and CH1.

following is my code.

I am getting only 1st sensor value on display . What is incorrect in code ? Is ADCSequenceDataGet(ADC_BASE, 0, &ulValue[0])  used only at once ? 

int
main(void)
{
 tContext sContext;

 unsigned long ulValue[2],x,y;

char g_Temp_1[32];
 char g_Temp_2[32];
//
// Set the clocking to run from the PLL.
//
SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);

SysTickPeriodSet(SysCtlClockGet() / TICKS_PER_SECOND);
SysTickIntEnable();
SysTickEnable();

// Enable Interrupts
IntMasterEnable();

//
// Initialize the display driver.
//
Formike240x320x16_ILI9320Init();

//
// Turn on the backlight.
//
Formike240x320x16_ILI9320BacklightOn();

GrContextInit(&sContext, &g_sFormike240x320x16_ILI9320);


SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC);

SysCtlADCSpeedSet(SYSCTL_ADCSPEED_500KSPS);


ADCSequenceConfigure(ADC_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);

 ADCSequenceStepConfigure (ADC_BASE, 0, 0, ADC_CTL_CH0);

ADCSequenceStepConfigure(ADC_BASE, 0, 0, ADC_CTL_IE | ADC_CTL_END | ADC_CTL_CH1);

ADCSequenceEnable(ADC_BASE, 0);
//
// Trigger the sample sequence.
//
ADCProcessorTrigger(ADC_BASE, 0);

IntEnable(INT_ADC0);

ADCIntRegister (ADC_BASE, 0, ADCIntHandler);

//
// Wait until the sample sequence has completed.
//
while(!ADCIntStatus(ADC_BASE, 0, false))
{
}
// Read the value from the ADC.
//
ADCSequenceDataGet(ADC_BASE, 0, &ulValue[0]);


 x = (ulValue[0] * 0.2932);

usprintf(g_Temp_1," Temperature: %d deg C ",x);

GrContextForegroundSet(&sContext, ClrBlueViolet);

GrContextFontSet(&sContext, &g_sFontCm20b);
GrStringDrawCentered(&sContext, g_Temp_1, 32,GrContextDpyWidthGet(&sContext) / 2, GrContextDpyHeightGet(&sContext) / 4, 0);

y = (ulValue[1] * 0.48876);

 usprintf(g_Temp_2," Temperature: %d deg C ",y);

 GrContextForegroundSet(&sContext, ClrRed);
 GrContextFontSet(&sContext, &g_sFontCm20b);
 GrStringDrawCentered(&sContext, g_Temp_2, 32, GrContextDpyWidthGet(&sContext) / 2,  GrContextDpyHeightGet(&sContext) / 2, 0);

//
// Flush any cached drawing operations.
//
GrFlush(&sContext);

}

 


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>