TASK_SWITCH_FROM_ISR crashs – portYIELD not

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

TASK_SWITCH_FROM_ISR crashs – portYIELD not

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?

TASK_SWITCH_FROM_ISR crashs – portYIELD not

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                  }