Quality RTOS & Embedded Software

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


TaskYIELD in critical section

Posted by Joseph Dupre on July 13, 2010
Is it appropriate/allowed to call taskYIELD() in a critical section??? I am attempting to have a UART send a break signal for a time period less than the tick frequency if possible.

U2LCR |= serBREAK;

timestamp = timer3GetValue();
while (timer3GetValue() - timestamp < 500) {

U2LCR &= ~serBREAK;

If this code is bogus, is there a way to have my break sent for a period less than the tick frequency without halting everything for the duration?

RE: TaskYIELD in critical section

Posted by Richard Damon on July 14, 2010
I am not sure if it will work on all ports, but it will (sort of) on many. Where it works, the YIELD effectively ends the critical section until that task restarts (so it might not be doing what you want). A few comments though, only tasks of the same priority will be able to get time from the YIELD, lower priority tasks will stay blocked. Also, if there are other tasks on this level that are ready, this task won't get restarted from the YIELD until all of them YIELD themselves from either an explicit YIELD, blocking for something, or running when a timer tick expires, do it may well be longer than a timer tick before it get restarted.

A second comment, is that your probably don't really need a critical section, you may just need to disable that serial ports interrupt and set a flag for the transmit routine to not try to send during the break.

[ 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