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


Interrupts on a Cortex M4, BASEPRI register

Posted by cablecoder on February 24, 2017

I am using FreeRTOS on a Cortex M4 platform (specifically an EFM32 from Silicon Labs). I'm doing a bunch of setup prior to starting the operating system; allocating things, creating the semaphores I'll need, etc. These make calls to things like pvPortMalloc and xSemaphoreCreateBinary. I've noticed that these calls will alter the BASEPRI register to a value of 0xA000. This masks off a bunch of interrupts, and essentially makes it so that the system won't trigger interrupts that aren't the highest priority until freeRTOS has started the scheduler.

I can get by with calling malloc instead of pvPortMalloc when freeRTOS isn't running, but I need to call xSemaphoreCreateBinary. Can someone tell me how to properly allow this call to be made prior to the scheduler being started, such that I can still have interrupts working? I've tried just calling "setBASEPRIO(0)", but this causes me to hit an Assert once the scheduler is running and an interrupt fires. Even if I manually call "setBASEPRIO(191)" before starting the scheduler.

Interrupts on a Cortex M4, BASEPRI register

Posted by rtel on February 24, 2017

Most of the FreeRTOS API functions are designed to leave interrupt disabled if they are called before the scheduler has started. This dates back to a time when a lot of support requests resulted from interrupts in application code trying to use the FreeRTOS API before the scheduler was started. If interrupt are disable between the FreeRTOS API first being used and the scheduler being started then that can't happen. You can manually set the basepri back to 0, or alternatively create a configuration task, start the scheduler, perform any initialisation you want from the configuration task, then re-purpose the configuration task once the configuration is complete.

Interrupts on a Cortex M4, BASEPRI register

Posted by cablecoder on February 27, 2017

Ah, I had an additional problem with an interrupt being set to too high of a priority, which I'd added while attempting to diagnose the problem originally. Thanks!

[ 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