2025-06-11 2:53 AM - last edited on 2025-06-11 3:03 AM by mƎALLEm
Question moved from this thread (a new question)
Thank you very much for the solution. However, I’m still unclear about the core point.
My main concern is that I need CAN files such that, when the code is flashed onto the STM32L4R9I-EVAL board, it should behave in the following way: upon receiving a CAN message, the board should either print something which is predefined or perform an action in response to that message.
Could you please help me with this
2025-06-11 3:07 AM - edited 2025-06-11 3:30 AM
Hello,
I recommend to use the Rx interrupts.
To print messages, you need to do it outside the interrupt handlers and the callback. You can for example set a flag in the interrupt handler and in the main if you check that flag was set, print the message you want.
If for example you need to toggle a LED, you can do it inside the interrupt.
You can inspire from this example: https://github.com/STMicroelectronics/STM32CubeF4/blob/master/Projects/STM324xG_EVAL/Examples/CAN/CAN_Networking/Src/main.c
Hope that helps.
2025-06-11 3:53 AM
@sonic_solutions wrote:should behave in the following way: upon receiving a CAN message, the board should either print something which is predefined or perform an action in response to that message.
Well, that's pretty much the definition of any embedded system: it receives events from external interfaces, and then does something in response.
Your job, as the embedded system developer, is to write the code to implement that something.
As @mƎALLEm said, that might typically involve saving any data from the interrupt and/or setting a flag (or flags) to tell the rest of your code that data is available, and to do its work on it.