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

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.

    portENTER_CRITICAL();
U2LCR |= serBREAK;

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

U2LCR &= ~serBREAK;
portEXIT_CRITICAL();


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