Quality RTOS & Embedded Software

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


Loading

ARM-7 Stack pointer register in different modes during context switches

Posted by dcgirish16 on September 17, 2014

Hi, I need a clarification regarding functions portSAVECONTEXT() & portRESTORECONTEXT() for ARM7 for example LPC-2129. These macros can be invoked from any where for example IRQ(timer interrupt) etc.. when the processor enters IRQ mode, stack pointer in use will be SPirq. What I could make out is, while saving the context or restoring, how is the SPsystem is accessed for saving or filling the stack pointer to or from TCB. in portRESTORE_CONTEXT() I could understand that the processor mode will be switched to system mode by "SUBS PC, LR, #4" but the stack pointer gets restored before that... could some one please clarify it?

Thanks, Girish


ARM-7 Stack pointer register in different modes during context switches

Posted by rtel on September 17, 2014

The comments in the code tell you where it is done:

/* Set R0 to point to the task stack pointer. */
"STMDB  SP,{SP}^                            nt"
"NOP                                        nt"
"SUB    SP, SP, #4                          nt"
"LDMIA  SP!,{R0}                            nt"
If you don't understand the assembly code then please refer to the ARM instruction set documentation.

Regards.


ARM-7 Stack pointer register in different modes during context switches

Posted by dcgirish16 on September 17, 2014

Thanks.. Yes I gone through the comment and even the assembly code.. but I had missed the meaning of "^" in the code.. sorry for that thanks a lot


ARM-7 Stack pointer register in different modes during context switches

Posted by dcgirish16 on September 17, 2014

Thanks.. Yes I gone through the comment and even the assembly code.. but I had missed the meaning of "^" in the code.. sorry for that thanks a lot


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


Careers

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

Renesas

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