XMC4800 CMSIS Rtos can’t handle interrupt thread properly

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User20030
Level 1
Level 1
We bought a Kit_XMC48_Relax_ECAT_V1 board and ran the sample program XMC4800 EhterCatAPP SSC Firmware updateSlave Example successfully.
We modified the example code by adding CMSIS RTOS for thread control. We created create two threads.

osThreadId etherCat_thread_id;
void etherCat_thread(void const *argument);
osThreadDef(etherCat_thread, osPriorityNormal, 1U, 512U);

osThreadId etherCat_Isr_id;
void etherCat_Isr_thread(void const *argument);
osThreadDef(etherCat_Isr_thread, osPriorityAboveNormal1, 1U, 512U);

void etherCat_thread(void const *argument) {
while (1) {
MainLoop( );
}
}

void etherCat_Isr_thread(void const *argument) {
while (1) {
osEvent evt1 = osSignalWait (0x0004 osWaitForever);
if (evt1.status == osEventSignal)
PDI_Isr();
}
}

The second thread is for a deferred interrupt handling. The following is the interrupt handler:

void ECAT0_0_IRQHandler(void)
{
osSignalSet (etherCat_Isr_id, 0x0004);
// PDI_Isr( ); // uncomment this line, etherCat_Isr_thread runs fine.
}

When running the program, etherCat_Isr_thread got stuck at osSignalWait and PSI_Isr() in the thread did not get executed. After un-commenting PDI_Isr()
in ECAT0_0_IRQHandler, both PDI_Isr() in the interrupt handler and PDI_Isr() in the thread will get executed. This is not what we expected. We just want
PDI_Isr( ) in the thread get executed but not PDI_Isr() in the interruption handler as it is not under thread control. How can we prevent PDI_Isr() running in the
interrupt handler?

Need your help to solve the problem. If you need any more information or the modified example project, please let us know.
0 Likes
2 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

One possibility is that the event status which triggers the service request is not being cleared and then the IRQ handler is invoked continuously. If the IRQ of the ECAT0 has a higher priority than the SysTimer, the scheduler will never run.

Can you check with the code below to see if the thread is waked up now?

volatile uint16_t ALEvent;

void ECAT0_0_IRQHandler(void)
{
osSignalSet (etherCat_Isr_id, 0x0004);
ALEvent = HW_GetALEventRegister_Isr();
}


Still it will not work since the PDI_Isr() checks the event flags which have been cleared, but it will help finding the root cause.

Regards,
Jesus
0 Likes
User20030
Level 1
Level 1
I run the firmware and did CTT testing without any problem after un-commenting PDI_Isr() in ECAT0_0_IRQHandler, Although I still don't understand why this is the case, I think I am fine now.
Than yo very much anyway!
0 Likes