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

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,
Fabien

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.

Regards.

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,
Fabien


[ 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