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() causes hang inPIC24f interupt

Posted by Sean on November 16, 2010
Per the FreeRTOS documentation to handle API calls inside of an interrupt I need to taskYIELD if necessary, I have the following ISR:

void __attribute__ ((__interrupt__, no_auto_psv)) _T4Interrupt(void)
{
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
IFS1bits.T4IF = 0;

xQueueSendToBackFromISR(queue_name, &queue_data, &xHigherPriorityTaskWoken);

if(xHigherPriorityTaskWoken == pdTRUE)
{
taskYIELD(); // Force context switch
}

Everytime xHigherPriorityTaskWoken is true and the taskYIELD() executes, my processor resets. I've debugged to determine this is correct. If I comment out the taskYIELD, everything works smoothly.

The only thing I can think is that the priority of this interrupt is 7 and the tick timer has priority 1, but I'm not disabling any interrupts and per the RTOS docs this should be the correct method to use.

RE: taskYIELD() causes hang inPIC24f interupt

Posted by Ricky on November 16, 2010
The correct function to use to switch tasks inside an interrupt is vTaskSwitchContext, not taskYield. So your code should look like this:

if(xHigherPriorityTaskWoken == pdTRUE)
{
vTaskSwitchContext(); // Force context switch
}

RE: taskYIELD() causes hang inPIC24f interupt

Posted by Richard on November 16, 2010
I think in this case calling taskYIELD() is the correct thing to do - but this must be done as the very last thing in the ISR routine. Is it the last line of executable code?

FreeRTOS\Demo\PIC24_MPLAB\serial\serial.c has an example ISR.

Regards.

RE: taskYIELD() causes hang inPIC24f interupt

Posted by Sean on November 16, 2010
I've solved the problem. It turns out I was getting a stack overflow on my IDLE task. I had been assuming that the stack used for interrupts was from the task executing when the interrupt occurred which wouldn't have caused any stack issues.

Could someone shed some light on what consumes the IDLE task's stack during operation? (I have no user defined IDLE hook or anything that should be used during idle time).

(It looks like taskYIELD() is correct, when I switched it out with vTaskSwitchContext() I got strange behavior)


[ 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