Hello everyone.
I'm new using the TM4C129x, for the moment I want to read values from two ADC channels with the ADC1 (because I see that ADC0 is used by the touchscreen) and at the same time use the touchscreen, everything working in FreeRTOS.
The problem is that when I try to put them to work together the touch doesn't work, I have a task to control the ADC and another for the LCD, both tasks have the same priority.
I have check the individual codes running alone and both works but when I try to put them together it fails the touch. Below I leave you what I think is the important code
First the ADC configuration:
void
InitADC(void)
{
//
// Habilita el módulo del ADC1
//
ROM_SysCtlPeripheralDisable(SYSCTL_PERIPH_ADC1);
ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_ADC1);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
while(!(ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_ADC1)));
//
// Habilita el puerto E (Ahí están los canales del ADC que vamos a usar)
//
ROM_SysCtlPeripheralDisable(SYSCTL_PERIPH_GPIOE);
ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOE);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
while(!(ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOE)));
//******************************************************************************
//
// Start the ADC sequence configuration
//
//******************************************************************************
//
// Configura dos pines del puerto E (E1 y E2) como entradas del ADC
//
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2);
//
// Configura el ADC para trabajar a 16MHz (480MHz(reloj principal) entre 30(prescaler))
//
ADCClockConfigSet(ADC1_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL, 30);
//
// Configura el secuenciador 0 del ADC1 para que sea disparado por software
// con prioridad 0
//
ROM_ADCSequenceConfigure(ADC1_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
//
// Configura los steps del secuenciador 0 para tomar una muestra del canal 0
// y después una muestra del canal 1, esta última muestra dispara la
// interrupción del ADC y finaliza la secuencia.
//
ROM_ADCSequenceStepConfigure(ADC1_BASE, 0, 0, ADC_CTL_CH0);
ROM_ADCSequenceStepConfigure(ADC1_BASE, 0, 1, ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END);
//
// Limpia la interrupción del ADC antes de habilitarla para evitar falsos
// disparos.
//
ADCIntClearEx(ADC1_BASE, ADC_INT_SS0);
ROM_ADCIntEnableEx(ADC1_BASE, ADC_INT_SS0);
//
// Habilitamos el secuenciador 0 para que comience el muestreo
//
ROM_ADCSequenceEnable(ADC1_BASE, 0);
//******************************************************************************
//
// Finish the ADC sequence configuration
//
//******************************************************************************
//
// Se habilita la interrupción del ADC
//
ROM_IntEnable(INT_ADC1SS0);
}
ADC interrupt handler:
void
ADC1SS0IntHandler(void)
{
uint32_t samples[NUM_SAMPLES];
int iRetVal = 0;
//
// Clear any pending status
//
ADCIntClearEx(ADC1_BASE, ADC_INT_SS0);
//
// Lee el valor obtenido por el ADC
//
iRetVal = ADCSequenceDataGet(ADC1_BASE, 0, samples);
if(iRetVal == 2)
{
//Some calculations
}
}
ADC Task:
void
ADCTask(void *pvParameters)
{
//
// Habilita el reloj para el TIMER0
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
//
// Habilita interrupciones del procesador
//
ROM_IntMasterEnable();
//
// Configura el submodulo TIMER_A del modulo TIMER0
//
ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, 120000);
//
// Setup the interrupts for the timer timeouts.
//
ROM_IntEnable(INT_TIMER0A);
ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
//
// Habilita los timers
//
ROM_TimerEnable(TIMER0_BASE, TIMER_A);
InitADC();
while(1)
{
if(DoOperations)
{
DoOperations = false;
TOCOandBPMCalculation();
}
}
}
Display Task
void
WidgetTask(void *pvParameters)
{
//
// Add the compile-time defined widgets to the widget tree.
//
GetScreen(1,&Imagen_a_mostrar);
WidgetAdd((tWidget*)&g_sBackground, (tWidget*)Imagen_a_mostrar);
WidgetAdd(WIDGET_ROOT,(tWidget*)&g_sBackground);
//
// Paint the widget tree to make sure they all appear on the display.
//
WidgetPaint(WIDGET_ROOT);
//
// Loop forever, processing widget messages.
//
while(1)
{
//
// Process any messages from or for the widgets.
//
WidgetMessageQueueProcess();
}
}
Sorry for the code in Spanglish, I hope you can help me and feel free to ask for more parts of the code and I'm using IAR by the way.
Regards, Juan




