Quality RTOS & Embedded Software

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


ISB isntructions on Cortex-M4 port

Posted by npoulokefalos on March 11, 2017


I have a question for the ISB instruction usage in GCC ARM_CM4F port [FreeRTOS v9.0.0].

It is used inside xPortPendSVHandler() after:

"    mrs r0, psp                            \n"
"    isb    

and after:

"    msr psp, r0                            \n"
"    isb    

In constrast, ISB is not used in the GCC ARMCM4MPU port when PSP is loaded/stored. Is there any reason for why this is required in one case and not to the other? I just need to verify that i am not missing something.

I am also curious about the ISB in the fist scenario, after "mrs r0, psp". Why it is needed?

ISB isntructions on Cortex-M4 port

Posted by rtel on March 12, 2017

The ISB instructions are required to be in strict compliance with the ARM Cortex-M specification. However for a long time actual purchasable implementations of the architecture did not, in practice, need the instructions. That changed a little while back, especially when the Cortex-M7 came out, and as the Cortex-M4F port is also used on Cortex-M7 chips the Cortex-M7 port was updated accordingly. The instructions should also be included in the MPU port too, as they become more relevant, and will be added.

ISB isntructions on Cortex-M4 port

Posted by npoulokefalos on March 12, 2017

Thanks for the reply,

To my knowledge, at least for te M4 port, the ISB would be required when MSR is used on the stack pointer currently used. Etc "MSR msp, r0" from whithin an ISR with subsequent push/pop instructions or in thread mode if MSP is also used there.

I am not familiar with Cortex M7, but is there any actual case where "MRS r0, psp" (not MSR) would require an ISB? Or it is just used after MSR/MRS in any case -- even if next instructions does not require it, just to be inline with the specification?

ISB isntructions on Cortex-M4 port

Posted by rtel on March 12, 2017

You may be right, that it is not required when moving from a special purpose register into a general purpose register. Having a look at the the source code I can only see one place where an MRS is followed by an ISB, and that is at the start of the PendSV handler.

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

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

Latest News

Version 10.1.0 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