Quality RTOS & Embedded Software

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


Context switching problem

Posted by Ricky on March 27, 2007
I'm developing a test application under ARM9 (STR912F) with 2 tasks controlling the UART. Initialization seems to run smoothly until the first task switch occurs. In the portRESTORE_CONTEXT macro (in ISR_Support.h), the instruction "LDMFDLR, {R0-R14}^" restores all registers for the task, including LR which now contains 0xAAAAAAAA (this value was set in the pxPortInitialiseStack function). However, the next instruction is LDR LR, [LR, #+60] which reads the return address from 0xAAAAAAAA+60 which is a garbage address. The value read is 0x00000000. What am I missing here?

RE: Context switching problem

Posted by Nobody/Anonymous on March 27, 2007
This is a bang on symptom of the processor not being in Supervisor mode when the context of the task is restored.

Are you starting in Supervisor mode? Are interrupts occurring that use the UART prior to the scheduler being started? Your answers should be "yes", "no", respectively.


RE: Context switching problem

Posted by Ricky on March 29, 2007
The processor was starting in User mode. I was using the wrong set of library files. I downloaded the updated ones from ST and was using them instead of the ones from FreeRTOS. I added the line to enter Supervisor mode and it works. Thanks!

[ 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.

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