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

vTaskResume in an ISR

Posted by Nobody/Anonymous on July 23, 2005
I'm playing with the LPC2106 + GCC ... it seems that vTaskResume has an issue (causes a pabort when it starts going through taskEXIT_CRITICAL()) when it's executed from the ISR. I was just wondering if this is normal before I start poking the port files...I have a timerISR that should resume the suspended task... I guess I could use the vTaskDelay but the timer provides me with exact timing which is kind of important in this case...

RE: vTaskResume in an ISR

Posted by Richard on July 23, 2005
vTaskResume() can cause portYIELD() to be called. This will happen if the task being resumed has a priority higher than the calling task – or in your case if the task being resumed has a priority higher than the task that was interrupted.

Generally care must be taken using portYIELD() from within an ISR. How it works is port dependent. In general, it should only ever be used at the end of an ISR.

If your application needs to do this then I suggest creating a xTaskResumeFromISR() function. This would return whether or not a context switch is required or not, rather than actually perform the context switch. This would be easy to do – take a look at the function xTaskResume(). You will see the variable xYieldRequired – this should be returned and the call to portYIELD() removed.

This is then the equivalent to the xQueueSend() and xQueueSendFromISR() functions. You cant take a look at these two functions to see what I mean, and take a look at the FreeRTOS\Demo\ARM7_LPC2106_GCC\serial\serialISR.c file to see how they are used. In serialISR.c the function vUART_ISR() uses xQueueReceiveFromISR() and xQueueSendFromISR(). The idea is that rather than have these function perform a context switch (which you don’t want from the middle of the ISR), they return whether or not a switch is required. Then at the end of the ISR – when everything is cleaned up and the interrupt serviced and reset – you can perform the context switch if required by calling portEXIT_SWITCHING_ISR(). Note also that you require portENTER_SWITCHING_ISR() at the top of the ISR.

An exact timing can be created for a task using vTaskDelayUntil() – providing the tick frequency is an exact multiple of the period you require.

Regards.


[ 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