sijomon1234 wrote on Wednesday, March 16, 2016:
Hi,
I have been working around with a mechanism with in tiva tm4c1294 micrcontroller, where two ADCs will periodically send interrupts and the the interrrupt isrs will post task notifications to an ADC process task, where the task is waiting with xtasknotifywait api.
My issue is I could see the task getting triggered from the isr, the task notification value in the tcb structure of the
task getting changed accordingly. But my task is not getting unblocked.
Here is my adc code:
/* * ADC_Config.c * * Created on: Mar 13, 2016 * Author: index */ #include #include #include "inc/hw_gpio.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/rom.h" #include "driverlib/rom_map.h" #include "FreeRTOS.h" #include "task.h" #include "queue.h" #include "semphr.h" #include "driverlib/sysctl.h" #include "drivers/pinout.h" #include "driverlib/adc.h" #include "ADC_Config.h" void ADCConfig(void) { MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); MAP_SysCtlPeripheralReset(SYSCTL_PERIPH_ADC0); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1); MAP_SysCtlPeripheralReset(SYSCTL_PERIPH_ADC1); // // Configure the ADC to use PLL at 480 MHz divided by 16 to get an ADC // clock of 30 MHz. // ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL, 16);//ADC0 and ADC1 are configured with ADC0 itself ADCIntRegister(ADC0_BASE, SEQ0,ADC0_INT_Handler); ADCIntRegister(ADC1_BASE, SEQ0,ADC1_INT_Handler); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);//AIN3-AIN2(PE3-PE2), AIN1-AIN0(PE1-PE0), differential mode MAP_GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 ); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);//AIN4(PD3) ,AIN12(PD7) MAP_GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_3 | GPIO_PIN_7); MAP_ADCSequenceDisable(ADC0_BASE, SEQ0); MAP_ADCSequenceDisable(ADC0_BASE, SEQ1); MAP_ADCSequenceDisable(ADC0_BASE, SEQ2); MAP_ADCSequenceDisable(ADC0_BASE, SEQ3);//All sequencers disabled. MAP_ADCSequenceConfigure(ADC0_BASE, SEQ0, ADC_TRIGGER_PROCESSOR, PriorityVeryHigh); //Technique to get simultaneous sampling from sequential sampling, Avg corresponding results, you get the simultaneously sampled result. MAP_ADCSequenceStepConfigure(ADC0_BASE,SEQ0, 0, ADC_CTL_SHOLD_256 | ADC_CTL_D|ADC_CTL_CH0);//VoltageSense MAP_ADCSequenceStepConfigure(ADC0_BASE,SEQ0, 1, ADC_CTL_SHOLD_256 | ADC_CTL_D|ADC_CTL_CH1);//CurrentSense MAP_ADCSequenceStepConfigure(ADC0_BASE,SEQ0, 2, ADC_CTL_SHOLD_256 | ADC_CTL_D|ADC_CTL_CH1);//CurrentSense MAP_ADCSequenceStepConfigure(ADC0_BASE,SEQ0, 3, ADC_CTL_SHOLD_256 | ADC_CTL_D|ADC_CTL_CH0);//VoltageSense MAP_ADCSequenceStepConfigure(ADC0_BASE,SEQ0, 4, ADC_CTL_SHOLD_256 | ADC_CTL_D|ADC_CTL_CH0);//VoltageSense MAP_ADCSequenceStepConfigure(ADC0_BASE,SEQ0, 5, ADC_CTL_SHOLD_256 | ADC_CTL_D|ADC_CTL_CH1);//CurrentSense MAP_ADCSequenceStepConfigure(ADC0_BASE,SEQ0, 6, ADC_CTL_SHOLD_256 | ADC_CTL_D|ADC_CTL_CH1);//CurrentSense MAP_ADCSequenceStepConfigure(ADC0_BASE,SEQ0, 7, ADC_CTL_SHOLD_256 | ADC_CTL_D|ADC_CTL_CH0| ADC_CTL_IE |ADC_CTL_END);//VoltageSense, Ending the sequence\ MAP_ADCSequenceDisable(ADC1_BASE, SEQ0); MAP_ADCSequenceDisable(ADC1_BASE, SEQ1); MAP_ADCSequenceDisable(ADC1_BASE, SEQ2); MAP_ADCSequenceDisable(ADC1_BASE, SEQ3);//All sequencers disabled. MAP_ADCSequenceConfigure(ADC1_BASE, SEQ0, ADC_TRIGGER_PROCESSOR, PriorityVeryHigh); MAP_ADCSequenceStepConfigure(ADC1_BASE,SEQ0, 0, ADC_CTL_SHOLD_256 | ADC_CTL_CH12);//DCVoltageSense MAP_ADCSequenceStepConfigure(ADC1_BASE,SEQ0, 1, ADC_CTL_SHOLD_256 | ADC_CTL_CH4);//DCCurrentSense MAP_ADCSequenceStepConfigure(ADC1_BASE,SEQ0, 2, ADC_CTL_SHOLD_256 | ADC_CTL_CH12);//DCVoltageSense MAP_ADCSequenceStepConfigure(ADC1_BASE,SEQ0, 3, ADC_CTL_SHOLD_256 | ADC_CTL_CH4);//DCCurrentSense MAP_ADCSequenceStepConfigure(ADC1_BASE,SEQ0, 4, ADC_CTL_SHOLD_256 | ADC_CTL_CH12);//DCVoltageSense MAP_ADCSequenceStepConfigure(ADC1_BASE,SEQ0, 5, ADC_CTL_SHOLD_256 | ADC_CTL_CH4);//DCCurrentSense MAP_ADCSequenceStepConfigure(ADC1_BASE,SEQ0, 6, ADC_CTL_SHOLD_256 | ADC_CTL_TS);//Temperature Sensor MAP_ADCSequenceStepConfigure(ADC1_BASE,SEQ0, 7, ADC_CTL_SHOLD_256 | ADC_CTL_TS| ADC_CTL_END | ADC_CTL_IE);//Temperature Sensor, Ending the sequence MAP_ADCSequenceEnable(ADC0_BASE, SEQ0);//sequencers are enabled MAP_ADCSequenceEnable(ADC1_BASE, SEQ0); //MAP_ADCIntEnable(ADC0_BASE, SEQ0); //MAP_ADCIntEnable(ADC1_BASE, SEQ0); } uint32_t uiDataBuffer0[8]; uint32_t uiDataCount0,uiADC0_Misalign = 0,ADC0_Counter=0; extern xTaskHandle xADC_DataProcessTaskHandle; #define ADC0_Notification (0x01) #define ADC1_Notification (0x02) void ADC0_INT_Handler(void) { portBASE_TYPE pxHigherPriorityTaskWoken = pdFALSE; ADCIntClear(ADC0_BASE, SEQ0); ADC0_Counter++; xTaskNotifyFromISR(xADC_DataProcessTaskHandle, (uint32_t)ADC0_Notification, eSetBits, &pxHigherPriorityTaskWoken); portYIELD_FROM_ISR(pxHigherPriorityTaskWoken); } uint32_t uiDataBuffer1[8]; uint32_t uiDataCount1,uiADC1_Misalign=0,ADC1_Counter=0; void ADC1_INT_Handler(void) { portBASE_TYPE pxHigherPriorityTaskWoken =pdFALSE; ADCIntClear(ADC1_BASE, SEQ0); ADC1_Counter++; xTaskNotifyFromISR(xADC_DataProcessTaskHandle, (uint32_t)ADC1_Notification, eSetBits, &pxHigherPriorityTaskWoken); portYIELD_FROM_ISR(pxHigherPriorityTaskWoken); } float fDieTemperature = 0.0; uint32_t ADC_DataProcessTaskEntryCounter=0; void ADC_DataProcessTask(void * pvParamerters) { uint32_t ui32NotifiedValue; for( ; ; ) { xTaskNotifyWait(pdFALSE, ULONG_MAX, &ui32NotifiedValue, portMAX_DELAY); fDieTemperature+=1.0; ADC_DataProcessTaskEntryCounter++; if( (ui32NotifiedValue & ADC0_Notification) != 0) { uiDataCount0 = ADCSequenceDataGet(ADC0_BASE, SEQ0, uiDataBuffer0); if(uiDataCount0 != 8) uiADC0_Misalign++; } else if( (ui32NotifiedValue & ADC1_Notification) != 0) { uiDataCount1 = ADCSequenceDataGet(ADC1_BASE, SEQ0, uiDataBuffer1); if(uiDataCount1 != 8) uiADC1_Misalign++; } } } First function is my ADC init. ADC0,ADC1 interrupt handlers are seen as second and third functions and last one is my task. Interrupts are found to be working fine. task is created in the main function like this. int main(void) { // // Configure the system frequency. // g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Configure the device pins for this board. // This application uses Ethernet but not USB. // //PinoutSet(true, false); ButtonsInit(); SPI3Config(); ADCConfig(); PWMConfig(); if(xTaskCreate(SSI_DAC_Task, (const portCHAR *)"SSI_DAC_Task ", SSI_DAC_TASK_STACK_SIZE, NULL, tskIDLE_PRIORITY + PRIORITY_SSI_DAC_TASK, &xSSI_DAC_TaskHandle) != pdTRUE) exit(1); if(xTaskCreate(ADC_DataProcessTask, (const portCHAR *)"ADC_ProcssTsk ", ADC_DataProcessTask_STACK_SIZE, NULL, tskIDLE_PRIORITY + PRIORITY_ADC_DataProcessTask, &xADC_DataProcessTaskHandle) != pdTRUE) exit(1); if(xTaskCreate(MasterControlTask, (const portCHAR *)"MasterCtlTsk ", MasterControlTask_STACK_SIZE, NULL, tskIDLE_PRIORITY + PRIORITY_MasterControlTask, &xMasterControlTaskHandle) != pdTRUE) exit(1); // // Start the scheduler. This should not return. // vTaskStartScheduler(); while(1);
What could be wrong?
Is there any problem with task notify apis?
regards
Sijomon