Hello, I’m new to FreeRTOS and I’m not sure which architectural approach with FreeRTOS I should use. My task is the following: I’m using an Infineon XMC4100 Cortex M4 with 80 MHz. I’m having a fast interrupt with 100 kHz triggered from a PWM. I would like to scale data and calculate 2 current controllers with 100 kHz. I would like to calculate some other controllers with 5 kHz. And I’m having slower communication tasks running in the backround. I tried do defer the 100kHz interrupt in a task using TaskNotifier. I measured the delay that causes the defering with digital IOs and a scope. It’s 4.5µs without any calculations which is too much if you have only 10µs in total. So the question is how to do this better? I could calculate the data scaling and current controllers directly in the interrupt, but that would need quite some calculation time and it is always recommended in the FreeRTOS docu to keep the interrupt short. So what would be the disadvantage of spending let’s say 50% of the time in an interrupt blocking the task scheduler? And what would be the best way to trigger a 5 kHz task? Or should I resign using FreeRTOS, but then the communication tasks would be more difficult to program. If I’m not having enough calculation time at all I could run the controllers with 50KHz instead of 100 kHz, but the problem is still similar. Any hints? Greetings, Tobias
10us period and 80 MHz processor says you have only 800 cycles per interrupt. You CAN’T have a ‘lengthy’ calculation that you need to do each cycle, as you don’t have much time there at all. I definitely would NOT defer that calculation from that interrupt as, as you noted, the overhead will be significant. You might have that ISR do a divide by 20 and defer, or setup another timer to run at 5kHz and have that trigger the lower speed calculation. This would also allow the 100kHz to not use any FreeRTOS API and thus be allowed to be high enogh priority that critical sections won’t block it, reducing the jitter on the interrupt.
I know I’m sort of short on calculation time, but as I said, probably I can also calculate the controllers with 50kHz which would give me 1600 cycles. But the problem with defering the interrupt would be the same, so thanks for your advice!
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.