Gotcha using CAN 2 on ARM microcontrollers (e.g., STM32F415 on 1Bitsy)
The short version: The CAN bus 2 channel on ARM microcontrollers only works if CAN 1 is also set up… That is, CAN 2 can not be set up independently; for it to work at all, the other CAN channel, CAN 1, must also be set up. This isn’t mentioned anywhere in the documentation, not even the slightest hint (not even when retrospectively searching for it).
This is demonstrated here for the 1Bitsy board (based on the STM32F415 microcontroller; STM32F415RGT6) and using Forth for exploration (Mecrisp Stellaris), but it is believed this problem applies to all ARM microcontrollers with more than one CAN channel.
Appendix B: Development board 1Bitsy
Schematics (in PDF format). Direct Git link.
Appendix C: Microcontroller STM32F415
The one on the 1Bitsy is:
- STM32F415RGT6
- STM32F415 32 bit 168 MHz
- ARM Cortex-M4F
- 192 KB RAM
- 1 MB Flash
- AES hardware acceleration
Appendix D: Forth system Mecrisp Stellaris
GitHub page. Direct Git link.
References
- STM32 Tutorial #49 – HOWTO CAN filters in detail (21 minutes). This video doesn’t cover the subject for this blog post, but it has some very detailed information for CAN on STM microcontrollers. See also the previous one, STM32 Tutorial Videos #48 – HOWTO use CAN. And this list of the videos on STM32World Wiki.
- STM32F4 – CAN bus transmit succeeds every time, but CAN receive only succeeds on the first call. It has “…in order to enable CAN2, CAN1 needs to be enabled”. This reference was found retrospectively.
Leave a Reply