# Interrupts on a Cortex M4, BASEPRI register

**URL:** <https://forums.freertos.org/t/interrupts-on-a-cortex-m4-basepri-register/6419>\
**Category:** Kernel\
**Created:** [February 24, 2017, 10:05pm UTC](https://forums.freertos.org/t/interrupts-on-a-cortex-m4-basepri-register/6419 "2017-02-24T22:05:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 24, 2017, 10:05pm UTC](https://forums.freertos.org/t/interrupts-on-a-cortex-m4-basepri-register/6419/1 "2017-02-24T22:05:31Z")

</div>

**[cablecoder](https://sourceforge.net/u/cablecoder/)** wrote on [Friday, February 24, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/7909e5e2/#f9a8):

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 “set\_BASEPRIO(0)”, but this causes me to hit an Assert once the scheduler _is_ running and an interrupt fires. Even if I _manually_ call “set\_BASEPRIO(191)” before starting the scheduler.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [February 24, 2017, 11:00pm UTC](https://forums.freertos.org/t/interrupts-on-a-cortex-m4-basepri-register/6419/2 "2017-02-24T23:00:27Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, February 24, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/7909e5e2/#f9a8/0456):

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.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 27, 2017, 2:43pm UTC](https://forums.freertos.org/t/interrupts-on-a-cortex-m4-basepri-register/6419/3 "2017-02-27T14:43:41Z")

</div>

**[cablecoder](https://sourceforge.net/u/cablecoder/)** wrote on [Monday, February 27, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/7909e5e2/#f9a8/0456/0b45):

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!
