Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Serial driver and Cortex M3

Posted by Reinhard Arlt on 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?


RE: Serial driver and Cortex M3

Posted by Richard on 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.


RE: Serial driver and Cortex M3

Posted by Reinhard Arlt on 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.

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner