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

FromISR functions outside of the ISR context

Posted by lpmay on February 23, 2017

I'm looking for clarification whether it is safe to call "FromISR" functions from outside an ISR. Below is the broader context of what I'm trying to do that is leading to this question.

I'm writing a software module which uses time from a RTC. My module has a task which consumes commands from a queue (very similar to the software timers in FreeRTOS). One of the functions in my API is called to indicate an RTC alarm went off, and loads a command into the queue. I want to abstract my module to work with several RTCs. If it is an internal RTC, this alarm function will likely be called from an ISR context and I would use the "FromISR" functions. However, if I'm using an external RTC, the interrupt source may have to be read over I2C or another slow bus before I can categorize it as the alarm going off - something I do not want to do in the ISR context. If my code still calls the "FromISR" functions in this case can that corrupt the kernel? I could #define my way through this, but I'd prefer to limit the amount of configuration users need to put in to use this code.

Thanks for your help!


FromISR functions outside of the ISR context

Posted by rtel on February 23, 2017

I'm looking for clarification whether it is safe to call "FromISR" functions from outside an ISR.

Yes....and no, depending on the port you are using.

You need to be careful with critical sections. If the port you are using supports interrupt nesting then you are probably ok, otherwise you will have to implement the portSETINTERRUPTMASKFROMISR() and portCLEARINTERRUPTMASKFROMISR() macros in such a way that they can be used from both an interrupt and a task.


FromISR functions outside of the ISR context

Posted by lpmay on February 24, 2017

Hi, thanks for the reply.

After thinking about it some more, I think I'll mirror the FreeRTOS API and have normal and "FromISR" versions of the function and leave it up to the user to call the appropriate one.

Thanks for the help!


[ 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