FreeRTos High Frequency ISR


Can anyone help me doing a task with high(like 6kHz) execution rate? Need to do a SPI transmission on this frequency(the task code is already written). I can achieve over 7kHz without any control(just one task with no timing control, running full time), so the time is not a problem(will fit).

The problem is that the TICK_RATE has a resolution of ms, which is too high for what I need. Doing some research I found that reducing the time resolution will cause an unwanted overhead.

So, the most recommended way would be using a ISR. Is that right? Couldn’t find an example of how doing that. I have almost null experience in FreeRTos.

Thanks in advance.

I would take a look at the gpt example in freertos-toradex/examples/imx7_colibri_m4/driver_examples/gpt. It shows how to use a clock with custom frequency. Instead of counting a clock you could then xSemaphoreGiveFromISR and wait in your task xSemaphoreTake. As for the semaphore I would use a xSemaphoreCreateBinary

Note: Take the BOARD_GPTA_RDC_PDAP part of the example, the BOARD_GPTB_RDC_PDAP uses the GptSysPllPfd0 clock and this can cause problems with the linux running

Thanks! Did it based on that example and solved my problem. Used GPTB using the ccmRootmuxGptOsc24m clock, because linux kernel was hanging using the Pfd0 clock. To get the frequency I needed just divided GPTB frequency by the desired frequency and passed to GPT_SetOutputCompareValue().

Perfect, that it works. Thanks for the feedback.