Quality RTOS & Embedded Software

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


Interrupts calling API before Scheduler start

Posted by Fabien on August 16, 2012
Hi all,

I'm still working on my first FreeRTOS project and I would like to have some advices on Interrupts management.

I have enable my interrupts at the beginning of my code, before calling vTaskStartScheduler(). I have some troubles and I think this happen when an interrupts is calling FreeRTOS API before my Scheduler is running. In order to avoid this, I find 2 ways:

1 - Check for each interrupts the State of Scheduler by using xTaskGetSchedulerState. I will call FreeRTOS API (FromISR) Only if Scheduler is running (taskSCHEDULER_RUNNING)

2 - Enable my interrupts in one Task, In order to be sure that Scheduler is running.

Do you think that one way is better? Or if you know a cleanest way to do this, don't hesitate to explain it to me.

Thanks for your help,
Best regards,

RE: Interrupts calling API before Scheduler start

Posted by Richard on August 16, 2012
If you call FreeRTOS API functions before the scheduler is started (which you must do, to create at least one task, if nothing else), then the kernel will leave interrupts disabled for this very reason. It also makes no sense to try and unblock a task, or access a kernel primitive, etc. from an interrupt is the task or primitive does not exist or the scheduler is not running.

Method 1 could work depending on the port, but note that only API functions that end in "FromISR" are guaranteed to be interrupt safe, so by doing this you are outside the stated scope of use. Also, you don't really want to be making an extra function call on every interrupt once the scheduler is running.

Method 2 is the preferred method. You can enable peripheral interrupts before the scheduler has started, if you leave global interrupts disabled. The RTOS kernel will enable global interrupts automatically when the first task starts running.


RE: Interrupts calling API before Scheduler start

Posted by Fabien on August 16, 2012
Hi Richard

Thanks a lot for your (very fast) answer.

Method 1: Thanks for your explantion. I forget that only function with "FromISR" is guaranteed inside interrupt.

I will implement the second method.

Best regards,

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

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

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

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

Cadence Tensilica Cortes

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