Electronic – CMSIS and sub millisecond delays

delayfreertosstm32f4

We are running FreeRTOS with CMSIS. Is it possible, using CMSIS on STM32F3 Discovery board, to have periodic tasks running with periods less than 1 millisecond resolution? We want to run tasks at 400 Hz, meaning the period should be 2.5 milliseconds. All functions pertaining to delays in CMSIS that i've found have millisecond resolution. Should we reconsider using CMSIS for our purposes?

EDIT 2:
A straight forward question now, hehe.
Could someone show me an example of how to setup a task to run periodically with a rate of 400 Hz with FreeRTOS, possibly using CMSIS but not limited to it, on STM32F3 Discovery board?

EDIT:
I will try to explain in more detail. The task is a PID controller that should run as fast as possible, but no faster than 432 Hz. So 400 Hz seemed like a round number. This means that 2 ms is a too short period. And the difference in task frequency between 2 ms and, say, 4 ms is quite dramatically. I don't quite know how much jitter we can accept, though. But it should probably not be in the millisecond range.

It seems more and more like we have to make use of the native FreeRTOS calls for the timing of tasks.

We would happily trade CPU utilization for greater timing accuracy since we won't probably make use of a great deal of the cycles in non-OS activity.

Best Answer

The granularity is probably a limitation from FreeRTOS, not from CMSIS itself.

Since you require a task every 2.5ms you might want to setup a timer to trigger every 2.5ms (Interrupt). Do what you have to do inside your interrupt (but keep it short) and get out as fast as possible. Usually there is hardware available for specific tasks, so if you can tell us something about your task at hand, there might be a better solution.