Doug McClean
Doug McClean

Reputation: 14485

Stack overflows after giving semaphore from ISR in FreeRTOS

I'm trying to use FreeRTOS's xSemaphoreGiveFromISR function and the accompanying portEND_SWITCHING_ISR macro to give a semaphore from within an interrupt that handles the end of an I2C transaction.

Every time I do, I end up in my program's application stack overflow hook function. The only change from a working version has been adding this line to the ISR, and I've doubled the size of the stack from 8192 to 16384 which didn't help.

Does anyone have thoughts about what gotcha is getting me?

My configCHECK_FOR_STACK_OVERFLOW value is 1.

Upvotes: 3

Views: 2259

Answers (1)

Damien
Damien

Reputation: 1552

You may want to check that the Interrupt is running at the same priority level than the RTOS configKERNEL_INTERRUPT_PRIORITY.

It's not unfortunately clearly stated.

I've run into the same problem as the RTOS default configuration set the interrupt priority lower than the default of the chip, at least for Microchip devices.

You also need to have enough memory for each task to handle the priority and if you have any taskYield it has to be the last instruction of the interrupt.

Upvotes: 1

Related Questions