Quality RTOS & Embedded Software

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


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 ]    [ Privacy ]    [ Sitemap ]    [ ]


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

Latest News

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

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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