Hi all,
I'am trying to display the ADC Data on my LCD Display . My problem is i'am not able to update the data continuously on the display.
Initially I've connected a potientometer on the ADC channel for testing purpose.
When I debug the code I get the pot value on the display once, but when i adjust the potentiometer the value does not change on the display screen. I know Iam missing something very small but i'am just not able to click it. below is my code. I've color highlighted all the diff functions for easy recognition
extern volatile uint32_t adcResult=0;
uint32_t ui32ADC0Value[1];
int main(Void)
{
//uint32_t i;
//uint32_t ui32ADC0Value[1];
/* Setup System Clock */
ui32SysClock = SysCtlClockFreqSet((SYSCTL_OSC_INT | SYSCTL_USE_PLL |
g_psDisplayMode->ui32VCOFrequency),
g_psDisplayMode->ui32SysClockFrequency);
g_ui32SysClock = ui32SysClock;
/* Initialize Peripherals */
PinoutSet();
Adc_Init();
g_pui16SDRAM = SDRAMInit(ui32SysClock);
if(!g_pui16SDRAM)
{
UARTprintf("Application requires SDRAM but this is not present!\n");
while(1);
}
g_pui32DisplayBuffer = (uint32_t *)g_pui16SDRAM;
g_pui16Palette = (uint16_t *)g_pui16SDRAM;
/* Launch GUI */
gui_Init();
/* Super Loop */
while(1)
{
/* Check for System Status Icons */
/* Take a break, Have a KitKat */
SysCtlDelay(ui32SysClock/100);
/* Handle UI Inputs */
WidgetMessageQueueProcess();
}
}
void Adc_Init()
{
SysCtlPeripheralDisable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralReset(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_ADC0)));
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOE)));
GPIOPinTypeADC(GPIO_PORTE_BASE,GPIO_PIN_5);
}
void Adc_Read()
{
ADCSequenceDisable(ADC0_BASE, 3);
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE,3,0,ADC_CTL_CH8|ADC_CTL_IE|ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 3);
ADCIntClear(ADC0_BASE, 3);
ADCProcessorTrigger(ADC0_BASE, 3);
while(!ADCIntStatus(ADC0_BASE, 3, false))
{
}
ADCSequenceDataGet(ADC0_BASE, 3, ui32ADC0Value);
adcResult= ui32ADC0Value[0];
}
*******************customized GUI display*******************
#include "common.h"
#include "homeUI.h"
#include "pixbuf.h"
#include "driverlib/sysctl.h"
#include "inc/hw_sysctl.h"
#include "utils/ustdlib.h"
#include "driverlib/adc.h"
//#include "grlib/Container.h"
extern volatile uint32_t ui32SysClock;
extern volatile uint32_t adcResult;
void gui_Init()
{
/* Initialize Graphics Driver */
DisplayInit(ui32SysClock);
GrRaster16BppDriverInit(g_pui32DisplayBuffer);
GrContextInit(&guiMainContext, &g_sGrRaster16BppDriver);
FillScreen(ClrBlack);
TouchScreenInit(ui32SysClock);
TouchScreenCallbackSet(WidgetPointerMessage);
WidgetAdd(WIDGET_ROOT, (tWidget *)&guiBackGround);
//WidgetAdd(WIDGET_ROOT, (tWidget *)&guiAcquisitionPage);
WidgetPaint(WIDGET_ROOT);
WidgetMessageQueueProcess();
void Adc_Read();
void OnIntroPaint(tWidget *psWidget, tContext *psContext);
}
Canvas(guiBackGround, WIDGET_ROOT, 0, 0, &g_sGrRaster16BppDriver,
X_OFFSET, Y_OFFSET, 800, 480,
CANVAS_STYLE_APP_DRAWN,
0, 0, 0, 0, 0, 0, OnIntroPaint);
void OnIntroPaint(tWidget *psWidget, tContext *psContext)
{
char sensorValue[100];
while(1)
{
Adc_Read();
usprintf(sensorValue,"%d", adcResult );
GrContextFontSet(psContext, g_psFontCmss32b);
GrContextForegroundSet(psContext, ClrCyan);
GrStringDraw(psContext, "Heart Rate = ", -1,
250, 250, 0);
GrStringDraw(psContext, sensorValue, 10,
500, 250, true);
WidgetPaint(WIDGET_ROOT);
}
}