STM32F429 with Canbus

Hello everyone,

I’m working on a project but my programming is becoming very complex. To divide the coding in smaller and more manageable pieces i would like to start using FreeRTOS. I have never used this before so i know i will have to learn a lot. My main concern is how should i use CANBus within freertos? Could somebody help me with some examples? Or just a basic RTOS example running on my specific micro controller(STM32F429ZIT)? I’ve already asked ST for some examples and searched trough the complete repository but i couldn’t find any example. I hope somebody here can help me to start using FreeRTOS. Thank you all

First you will want an interrupt driven CAN BUS driver (interrupt based drivers are basically essential when working in an RTOS). You then will typically create a task to handle receiving CAN BUS messages, decoding them, and sending out to other parts of the system notifications of the messages. This implies that you also need to partition the rest of your design into other tasks. I like to look at my system a create a task for each asynchronous input to the system (or possibly related groups of inputs).

This is so it can be event driven and therefore much more efficient. The interrupt that indicates the reception of a new CAN frame can wake a task that processes the frame - so the task never has to poll for CAN messages as anything that polls for something that is not there is wasting CPU time and power.

Thank you both for the feedback. Now everything makes more sense to me.
Are there any example projects available on how to use CANbus within freeRTOS?

You can look at the design of the TCP/IP stack https://github.com/FreeRTOS/FreeRTOS/blob/master/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_IP.c#L334 that uses event driven interfaces to the network - but that really would be starting at the complex end of the spectrum. For now I would just look at how to use something like a direct to task notification to create efficient event driven interrupt routines. I think there is a quick UART example in the book, or you can just start with the examples in the API documentation.

Wow, i didn’t knew about this book.I will certainly have a look at all this information.
I’ve already read a book about rtos systems, this book was using the KeilIDE and had very handy functions to check how long each task was active and see how running time was divided between tasks. Since i use the Cube IDE from STM( my micro controller supplier) i don’t think this is possible within this IDE. Is there an alternative way to see how the tasks are running?

For my first project version i just used the most performant micro controller i have experience with, it’s an STM32F429zit running at 180MHz. Since this is a rather expensive controller i’m planning to downgrade this and use another micro controller in the final version. I’m wondering how the CPU clock speed is related to the RTOS performance? Say for instance if i use a micro running at 100MHz, would this make a big difference on how the RTOS is working? I guess this depends on how complex/ the amount of tasks i have within my code?