I'm a beginner of RTOS programming and this is not a chibios specific question, but I hope someone can give me a short answer.
One aim of the application should be to do this every 5 ms:
Read out 2 sensors over SPI/I2C by DMA --> Calculate current state by a filter and new motor control values by pid-controller --> Send to motor driver over I2C/CAN
Now I don't really know what is the best way to handle this.
Without RTOS I would use hardware timers to get exact timing.
When now systick is 1000 Hz does it make sense to do this with something like this in the "DMA thread" and then give a semaphore to another thread when values have arrived: (from http://www.chibios.org/dokuwiki/doku.php?id=chibios:kb:timing)
Code: Select all
while (TRUE) {
time += MS2ST(1000); // Next deadline
do_something();
chThdSleepUntil(time);
}Or does it then has an accurateness of +- 1ms (systick), which is quite a large percentage in this case.
Is a better solution to use virtual timers or what would you suggest in this case?
Thanks for any replies!!
Best regards,
Florian