bremans wrote on Wednesday, January 22, 2014:
Hi,
I’m using the freertos-demo for stellaris launchpad lm4f and I’m trying to activate a task when an interrupt occurs.
I’ve been testing it on two different scenarios; when I press the left button the xSemaphoreGiveFromISR works and also the task responds but when I use this in the interrupthandler (GPIOPortDIntHandler) then xSemaphoreGiveFromISR works but the task isn’t responding and the system freezes after the amount of counts has reached its max? Could it be that the interrupts are coming too fast? I already set the xSemaphore to a counting semaphore…
I’m also using xSemaphoreTake because the xSemaphoreTakeFromISR is not available in this version.
Here is the code:
#define DHTTASKSTACKSIZE 128
#define DHTINTTASKSTACKSIZE 128
extern xQueueHandle g_pLEDQueue;
extern xSemaphoreHandle g_pUARTSemaphore;
extern xSemaphoreHandle xCountingSemaphore;
static
void DHT_Task(void *pvParameters){
unsigned char cMessage;
portTickType ulWakeTime;
unsigned long ulLEDToggleDelay;
ulLEDToggleDelay = 250;
ulWakeTime = xTaskGetTickCount();
while(1)
{
if(xQueueReceive(g_pLEDQueue, &cMessage, 0) == pdPASS)
{
if(cMessage == LEFT_BUTTON)
{
xSemaphoreGiveFromISR(xCountingSemaphore, NULL);
}
}
vTaskDelayUntil(&ulWakeTime, (ulLEDToggleDelay) / portTICK_RATE_MS);
}
}
void GPIOPortDIntHandler(void){
if(xSemaphoreGiveFromISR(xCountingSemaphore, NULL)){
UARTprintf("|");
}
}
void DHT_IntHandler(void *pvParameters){
while(1){
if(xSemaphoreTake(xCountingSemaphore, portMAX_DELAY)){
UARTprintf(".");
}
}
}
//DHT Task Initialisation
unsigned long
DHTTaskInit(void)
{
if(xTaskCreate(DHT_Task, (signed portCHAR *)“DHT”, DHTTASKSTACKSIZE, NULL, tskIDLE_PRIORITY + PRIORITY_DHT_TASK, NULL) != pdTRUE)
{
return(1);
}
if(xTaskCreate(DHT_IntHandler,(signed portCHAR *)"DHT_INT", DHTINTTASKSTACKSIZE, NULL, tskIDLE_PRIORITY + PRIORITY_DHT_INT_TASK, NULL) != pdTRUE){return(1);};
//
// Success.
//
return(0);
}
With kind regards,
Bart