Quality RTOS & Embedded Software

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


Details when to use xxxFromISR()?

Posted by iamtherealeimer on November 6, 2015

Hi guys,

I have a general question how to determine when to use the xxFromISR()-functions?

First, I know that in the case I misuse the "regular" function, I will most likely get an assert which points me to use the FromISR()-function. But I would like to understand the logic when to use one or the other.

For example: I am communicating with FreeRTOS via UART. I configured the TX and RX to be using the DMA. As soon as an internal buffer is full or I the termination-character is received, the data (in my case a string) is put onto to queues TX/RXQueue. Every package of data is signalled with the accroding callback,. As far as im concerned, the TX/RXCmpltCallbacks are not interrupts, or are they?

If I am not using the xQueueSendFromISR(), I am ending in an assert. So my guess is that I have a twist in my logic and I would like to untwist that. Or in other words: "How can I determine when to use FromISR or the regular function?"

Related to that question? If I use the xQueueReceiveFromISR-function do I need to be in an ISR or does the queued element is from an ISR?

Thank you for your time and help, I realy appreciate every input on the topic.


Details when to use xxxFromISR()?

Posted by rtel on November 6, 2015

If your Tx/Rx complete callback functions are called from the context on an interrupt service routine, then you will have to use the 'FromISR' version of the API functions. If they are called from the context of a task, then you can use either version (although using the 'FromISR' version from a task need care).

Using a DMA for the transmission sounds very efficient, which is good, so presumably you only have one interrupt being generated when the buffer is full (as you state) rather than lots of interrupts. That sounds ideal so far, but how are you then placing the string into a queue? If you place the whole string into a queue then it will definitely not be efficient, but if you are just queueing a pointer to the string then your set up sounds ideal.

When you are using an RTOS you also have the opportunity to defer interrupt processing to a task (so the ISR just unblocks a high priority task, then returns directly to the task, so interrupt processing occurs contigous in time just as if it had all been done in the ISR), and when executing from a task context you can use all the API functions. See the following link for some examples: http://www.freertos.org/RTOSTaskNotificationAsCounting_Semaphore.html

[ 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.

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.


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


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