Serial driver and Cortex M3

reinhard_arlt wrote on Tuesday, June 15, 2010:


while porting a small app, that runs on ARM7 and PowerPC ports of FreeRTOS, to a LPC1758, i had to find out, that i can not use API calls, that force a context switch in a taskENTER_CRITICAL() task_EXIT_CRITICAL() section. For example, the serial driver from the LPC2106 port do this.

Here xQueueSend() is called after a taskENTER_CRITICAL(), and the result is an infinite loop in “vListInsert()”.
The system tries to put the same task several times in the “xTasksWaitingToSend” of the tx queue, because it is not able to stop the task after it do so the first time, as the interrupts are off.

Is there an easy way to fix the serial driver?


rtel wrote on Tuesday, June 15, 2010:

The big difference between the Cortex-M3 port and the ARM7 port is that when the ARM7 port calls taskYIELD() it will yield immediately no matter where it is called from - and when the Cortex-M3 port calls taskYIELD() it will set an interrupt pend bit and therefore only actually yield once outside a critical section (if it was called from inside a critical section).

Hope that helps.


reinhard_arlt wrote on Wednesday, June 16, 2010:

The API  reference is a bit vague, if context switching API calls are allowed after a “taskENTER_CRITICAL()”.

From the fact, that for example the serial diver (Demo/ARM7_LPC2106_GCC/serial/serial.c) do it, and it is forbidden after a vTaskSuspendAll(), I have assumed up to now, that it is allowed.

An answer like: It is allowed on ARM7 and not on CORTEX-M3 would be a bit disappointing, as i think, that a kernel should provide the same API on all supported platforms.