FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [August 2007 Threads] TASK_SWITCH_FROM_ISR crashs - portYIELD notPosted 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 notPosted 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 notPosted 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 }
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|