Quality RTOS & Embedded Software

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



Posted by dre on April 24, 2008

I'm wondering if there is anyone that has an implementation of the taskYIELD_FROM_ISR for a SAM7X processor (IAR compiler) that they would be willing to share with me.

Also, what happens if I don't yield from isr when the message I just sent unblocks a higher priority task then the one currently running? Will the yield take place at the next tick then?



Posted by Maxim on April 24, 2008

I have no implementation of taskYIELD_FROM_ISR for a SAM7X processor, but I'll give you an idea how you can easily implement it on any ARM processor.

To yield from an ISR is a bit problematic because the ISR should return and leave the stack pointer & C.O. in the same state as before entering the ISR.
taskYIELD_FROM_ISR can be realized by raising a software interrupt in VIC. Choosing this implementation you should carefully use nested interrupts if at all. You can even use the same ISR as for the timer interrupt:

__asm void vPortTimerISR(void)

bl [C-function: if not SOFT interrupt -> call vTaskIncrementTick(), else clear SOFT interrupt]
bl vTaskSwitchContext


To make the context switch a bit faster you can use separate ISRs:
- timer ISR: performs context switch, increments OS tick, clears timer interrupt
- software ISR: performs context switch, clears software interrupt

I hope it will help you



Posted by Richard on April 24, 2008
The macro already exists, its just called something different. See the documentation page for the SAM7S IAR http://www.freertos.org/portsam7iar.html.

portEND_SWITCHING_ISR( ( cContextSwitchRequired ) ), under the interrupt service routine section.

To answer the other question. If you don't call this then the unblocked task will not run immediately once the interrupt has completed, but will get selected to run the next time the RTOS tick occurs.



Posted by dre on April 29, 2008


Posted by Mik Lamming on January 12, 2010
I notice that several of RIchard's excellent examples use task_YIELD_FROM_ISR My appolgies for being so dense but I was unable to find any explanation of the in the manual(s). Given that Richard is so thorough I am assuming I'm looking under the wrong rock :-)

I'm deducing that I need to write an implementation of that macro for any port to a "new" processor - including the ancient AVR mega128. Is that true? And is there some adjacent cast-iron implementation I can model mine upon?


Posted by sotd on January 12, 2010
AVR port can just call taskYIELD() in the interrupt. Most ports must not do this. Look at SIG_UART_RECV in Demo\AVR_ATMega323_WinAVR\serial\serial.c for an example.


Posted by Mik Lamming on January 12, 2010
sotd: thanks mgl

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


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