Search code examples
freertosisr

FreeRTos High Frequency ISR


Can anyone help me do 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.

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 way would be using an ISR. Is that right? Couldn't find an example of how do that. I have almost null experience in FreeRTos.

Using Toradex FreeRTOS version in Toradex IMX7D.

Thanks in advance.


Solution

  • Resolved it based on the solution in examples/imx7_colibri_m4/driver_examples/gpt(Toradex FreeRTOS version).

    Just used GPTB derived from ccmRootmuxGptOsc24m clock. This is important because linux kernel was hanging on startup using the default Pfd0 clock.

    To get the frequency I needed just divided GPTB frequency by the desired frequency and passed to GPT_SetOutputCompareValue().