Report
2 years, 3 months ago.

STM32L053 and CAN

Hi, I have a STM32L053 board and like to send messages via CAN bus. How can I do this? Do I need an additional board for this? Which libraries are available for this purpose?

Comment on this question

2 Answers

2 years, 3 months ago.

That micro does not seem to have CAN hardware on it. Path of least resistance is to just buy one that does. I have been using Nucleo_F091RC for this. $11 on Digikey, not bad. Suggest starting with micro in loopback mode. Connect the RD and TD pins together on the board so that it passes the module initialization test. And then set the can module into loopback.

<<code>> can.mode(CAN::LocalTest); <<code>>

The CAN class included in mbed os 5 CAN.h is the obvious starting point. Though fair warning, the lower level can_read() and can_write() functions are not very robust. Notably can_read() always returns true even if there is no data. If you are willing to put some time in, I'm sure they can be made to work. But if you want something working out of the box, zipping messages back and forth at a high rate, these won't work. The low level stuff is all micro-specific, so it is possible the implementation is more complete on micros from a different manufacturer.

Graham

2 years, 3 months ago.

Hello Peter,
If you prefer to add an external board then the Seeed Studios CAN-BUS Shield seems to support mbed, although I have never tried. Otherwise, to experiment with CAN bus, a would recommend to purchase two low cost (about 2$ a piece on eBay) STM32F103C8T6 boards and try the CAN_Hello or CANnucleo_Hello demos.


You need to log in to post a question