Quality RTOS & Embedded Software

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


Loading

TASK_SWITCH_FROM_ISR crashs - portYIELD not

Posted by mkrug on August 31, 2007
Hello,

I discovered something interesting with a HC12 (did the adoption to the existing HCS12 port on my own) that I can not explain at the moment.

I have a CAN interrupt receive service routine. If I overload the HC12 with high CAN message frequency the application crashs at the call of: portTASK_SWITCH_FROM_ISR() at the end of the interrupt service routine. If I replace it with portYIELD() it works perfectly. I looked to the stack pointer and it points on the same adress, regardless which of the task switch functions I am calling, right at the beginning and just before exiting the service routine. I use only 'static' variables in the service routine. Surprisingly the code for portTASK_SWITCH_FROM_ISR and portYIELD is exactly the same. The only difference in calling portYield is that within the interrupt service routine an other one (portYIELD) is called because the swi instruction is used. So an additional entry and exit to interrupt service routines are performed.

Anyone an idea what makes the difference ?

Best Regards
Markus

RE: TASK_SWITCH_FROM_ISR crashs - portYIELD not

Posted by Dave on August 31, 2007
Just reading the docs for the port I see "Note that portTASK_SWITCH_FROM_ISR() should only ever be used at the very end of an ISR and only when the ISR does not declare any non static local variables. If the ISR does use local variables then a call to portYIELD() can be used in place of the portTASK_SWITCH_FROM_ISR() macro." As your vars are static you are not using local variables.

It does not say that portTASK_SWITCH_FROM_ISR() should not be used when there are no local variables.

Is you call the last thing done in the ISR?

RE: TASK_SWITCH_FROM_ISR crashs - portYIELD not

Posted by mkrug on August 31, 2007
Hello Again,

below you find the original ISR code. I commented out the portTASK_SWITCH_FROM_ISR() command. In any case you can see that it is the very last command in the ISR. IDHIT, CORFLG and pdTRUE are global Variables. The local used ones are defined as 'static'.

Markus

ISR(CAN0_recv_ISR)
{
static unsigned char xYieldRequired = pdFALSE;
static unsigned char temp_reg_rec;

temp_reg_rec = C0RFLG;
temp_reg_rec = temp_reg_rec | 0x01;
C0RFLG = temp_reg_rec;

switch (IDHIT)
{
case 0x00:
{
/* CAN 0x100 was received */
xYieldRequired = xSemaphoreGiveFromISR( xSemaphoreCANID100, pdFALSE );
break;
}
case 0x01:
{
/* CAN 0x108 was received */
xYieldRequired = xSemaphoreGiveFromISR( xSemaphoreCANID108, pdFALSE );
break;
}
case 0x02:
{
/* CAN 0x118 was received */
xYieldRequired = xSemaphoreGiveFromISR( xSemaphoreCANID118, pdFALSE );
break;
}
case 0x03:
{
/* CAN 0x158 was received */
xYieldRequired = xSemaphoreGiveFromISR( xSemaphoreCANID158, pdFALSE );
break;
}
default:
break;
}


if( xYieldRequired == pdTRUE )
portYIELD();
//portTASK_SWITCH_FROM_ISR(); surprisingly does not work
}


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


Careers

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

Renesas

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