Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Use of barriers when setting BASEPRI on Cortex M7

Posted by kostas2010 on May 17, 2017

Raising BASEPRI on M7 port (v9.0.0) is done as below: ~~~

define portDISABLE_INTERRUPTS() vPortRaiseBASEPRI()

static portFORCE_INLINE void vPortRaiseBASEPRI( void )

{

uint32t ulNewBASEPRI = configMAXSYSCALLINTERRUPTPRIORITY;

__asm

{

	/* Set BASEPRI to the max syscall priority to effect a critical

	section. */

	cpsid i

	msr basepri, ulNewBASEPRI

	dsb

	isb

	cpsie i

}

}

~~~ Could you explain the need for a DSB?

Additionally, I understand that ISB is used to ensure that when this function returns, the BASEPRI change is observed. However this makes sense only if ISB is placed after "cpsie i" instruction so that the PRIMASK clear is also observed.

I have also looked into this (http://infocenter.arm.com/help/topic/com.arm.doc.dai0321a/DAI0321Aprogrammingguidememorybarriersform_profile.pdf) but I could not find the exact case in the guidelines.


Use of barriers when setting BASEPRI on Cortex M7

Posted by rtel on May 17, 2017

The cpsid/cpsie instructions are a workaround to a silicon errata and are only required if the revision of the core is r01p, otherwise use the Cortex-M4F port layer. I imagine the errata docs will be the only place they are mentioned.


Use of barriers when setting BASEPRI on Cortex M7

Posted by kostas2010 on May 18, 2017

Thank you for your answer.

What about the need for DSB? Is it required after the MSR instruction that sets BASEPRI?

(To help our discussion I am pasting the CM4F port that is suitable for our CM7 (non r0p1))

~~~ static portFORCEINLINE void vPortRaiseBASEPRI( void ) { uint32t ulNewBASEPRI = configMAXSYSCALLINTERRUPT_PRIORITY;

__asm
{
	/* Set BASEPRI to the max syscall priority to effect a critical
	section. */
	msr basepri, ulNewBASEPRI
	dsb
	isb
}

} ~~~


Use of barriers when setting BASEPRI on Cortex M7

Posted by rtel on May 18, 2017

On the M3 and M4 it is actually after the next instruction: "MSR side-effects are visible after one further instruction is executed". I believe it is different on the M7 though and will have to look it up. The M4F port was updated so it could also be used on an M7.


Use of barriers when setting BASEPRI on Cortex M7

Posted by kostas2010 on May 19, 2017

So, for M3/4 at least, removing the DSB instruction means that the side-effects will be visible after the ISB instruction, which is what we want. So it looks that practically there is no need for a DSB.

I will be waiting for your findings on M7 as well. Many thanks again for the help.


Use of barriers when setting BASEPRI on Cortex M7

Posted by kostas2010 on May 24, 2017

Any news on this?


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




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists