2018-04-17 01:52 PM
I am looking for a simple CAN Receive example for the STM32F042. The example I usually see cited (STM32072B_EVAL\Examples\CAN\CAN_Networking) is really all about sending a message when a button is pressed.
I'm using STM32CubeMX v4.25.0 along with the STM32CubeF0 Firmware Package V1.9.0.
What I need is a better understanding of how I can perform a non-blocking receive operation in my main loop.
I don't think I need interrupts or DMA - but if they're required, I'm OK with that.
My project is to listen to the CAN bus and when a specific message comes in, respond with a different specific message. This should be quite simple - but the documentation I've found so far is not clicking for me.
Thanks.
2018-04-17 02:02 PM
I just went though that. In the CAN_rx callback function I copied the CAN data to my own buffer and then set a global CAN_Received flag to true. I monitor the CAN_Received flag in the main loop and process my buffer with the CAN data at that time.
Oh, dont' forget to re-enable CAN receive after yo process the buffer.
Good luck.
2018-04-17 04:09 PM
Thanks! I'd missed the callback functions when I was looking through that example earlier.
This method should work well for me. In fact, it looks like they check the message and re-enable receives directly in the callback function.
And if it doesn't work, I'll be back! :)