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


Task stops executing and disappears while other tasks continues normally

Posted by inimicus8 on October 12, 2015

Hi I have a task that I resume from an interrupt. After some time (10 minutes too several hours) the task that gets resumed from the interrupt stop executing. This while all other tasks continues to function normally.

Interrupt code: void CANRXInterrupt( void ) { ……….. xYieldRequired = xTaskResumeFromISR( canHandle ); portYIELDFROMISR( xYieldRequired ); }

OS Task code: while (1) {


		vTaskSuspend( NULL );

When I call vTaskList() after the task have stopped working the effected task does not appear in the list anymore.

vTaskList() before CAN_T task stops executing: Name State Priority Stack Num

ShellT R 5 300 4 CANT R 1 428 3 IDLE R 0 491 6 IRT B 3 482 2 ErrorT B 6 483 5 Main_T B 2 460 1 Tmr Svc B 2 993 7 >

vTaskList() after CAN_T task stops executing: Name State Priority Stack Num

ErrorT R 6 483 5 IDLE R 0 491 6 ShellT B 5 300 4 IRT B 3 477 2 MainT B 2 460 1 Tmr Svc B 2 993 7

I don’t think its stack overflow because I don’t end up in the vApplicationStackOverflowHook() and there seems to be plenty of memory still available when I call vTaskList() before the task stops working. I also don’t get caught in the configASSERT .

Anyone having a clue what could be wrong here? Why does the task disappear from the vTaskList()?

Info about platform: MCU: stm32f407: IDE: coocox 2.0.3. toolchain: gcc 4.8 2004. RTOS: FreeRTOS V8.2.2

Task stops executing and disappears while other tasks continues normally

Posted by rtel on October 12, 2015

If you are using the task suspend/resme mechanism to synchronise a task with an interrupt, then please don't, it is a dangerous technique to use. Please read the documentation page of the xTaskResumeFromISR(), and other posts in this forum where people have experienced the same issue.

The best and fasted way to do what you want is to use a direct to task notificiation. See http://www.freertos.org/vTaskNotifyGiveFromISR.html


Task stops executing and disappears while other tasks continues normally

Posted by inimicus8 on October 12, 2015

Thank you for the reply! :-) I have tried using the vTaskNotifyGiveFromISR( canHandle, NULL ) but the program only runs for a couple of minutes before it ends up in the HardFault_Handler().

If I don’t call the portYIELDFROMISR( pdTRUE ) the program seems to work fine but the task is not started directly after the interrupt and that is not acceptable.

I don’t know why I get this problem but I guess it might have something with the interrupt priority settings. But as I understand it I think the settings are correct.

The interrupt priority for the interrupt calling vTaskNotifyGiveFromISR() and portYIELDFROMISR() is the following:

~~~~ NVICPriorityGroupConfig(NVICPriorityGroup4); NVICInitStructure.NVICIRQChannel = CAN1RX0IRQn; NVICInitStructure.NVICIRQChannelPreemptionPriority = 15; NVICInitStructure.NVICIRQChannelSubPriority = 15; NVICInitStructure.NVICIRQChannelCmd = ENABLE; NVICInit(&NVIC_InitStructure); ~~~~ This should be the lowest interrupt priority.

The freeRTOS config settings are:


define configMAXSYSCALLINTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11.


Task priority is: xTaskCreate( CAN_Control_Task, ( const char * ) "CAN_T", configMINIMAL_STACK_SIZE, NULL, 1, &canHandle );

Anyone having a clue of why I end up in hard fault when I use vTaskNotifyGiveFromISR and portYIELDFROMISR from an interrupt? Or how I investigate further how to track down the fault?

Task stops executing and disappears while other tasks continues normally

Posted by rtel on October 12, 2015

Try setting the SubPriority to 0. Are you also calling NVICPriorityGroupConfig( NVICPriorityGroup_4 );? (http://www.freertos.org/RTOS-Cortex-M3-M4.html). Do you have configASSERT() defined? Do you have stack overflow checking turned on?

[ 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