{"id":3579,"date":"2023-04-17T14:23:36","date_gmt":"2023-04-17T13:23:36","guid":{"rendered":"https:\/\/pmortensen.eu\/world2\/?p=3579"},"modified":"2025-09-18T20:03:31","modified_gmt":"2025-09-18T19:03:31","slug":"gotcha-using-can-2-on-arm-microcontrollers-stm32f415-1bitsy","status":"publish","type":"post","link":"https:\/\/pmortensen.eu\/world2\/2023\/04\/17\/gotcha-using-can-2-on-arm-microcontrollers-stm32f415-1bitsy\/","title":{"rendered":"Gotcha using CAN 2 on ARM microcontrollers (e.g., STM32F415 on 1Bitsy)"},"content":{"rendered":"<p>The short version: The <a href=\"https:\/\/en.wikipedia.org\/wiki\/CAN_bus\">CAN bus<\/a> 2 channel on <a href=\"https:\/\/en.wikipedia.org\/wiki\/ARM_architecture\">ARM<\/a> <a href=\"https:\/\/en.wikipedia.org\/wiki\/Microcontroller\">microcontrollers<\/a> <strong><em>only works if CAN 1 is also set up<\/em><\/strong>&#8230; 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&#8217;t mentioned anywhere in the documentation, not even the slightest hint (not even when retrospectively searching for it).<\/p>\n<p>This is demonstrated here for the <a href=\"https:\/\/1bitsquared.com\/products\/1bitsy\">1Bitsy<\/a> board (based on the <a href=\"https:\/\/www.st.com\/en\/microcontrollers-microprocessors\/stm32f415rg.html\">STM32F415<\/a> microcontroller; STM32F415RGT6) and using <a href=\"https:\/\/en.wikipedia.org\/wiki\/Forth_%28programming_language%29\">Forth<\/a> for exploration (<a href=\"https:\/\/mecrisp-stellaris-folkdoc.sourceforge.io\/\">Mecrisp Stellaris<\/a>), but it is believed this problem applies to all ARM microcontrollers with more than one CAN channel. <\/p>\n<p><!-- \n\n\n<h2>The problem<\/h2>\n\n\n\n<Actual symptoms>\n\n\n\n<h2>Using Forth for exploring the CAN hardware<\/h2>\n\n\n\n\n\n<h2>Appendix A: <\/h2>\n\n\n\n\n--><\/p>\n<h2>Appendix B: Development board 1Bitsy<\/h2>\n<p><a href=\"https:\/\/github.com\/1Bitsy\/1bitsy-hardware\">Schematics<\/a> (in PDF format). Direct <a href=\"https:\/\/github.com\/1Bitsy\/1bitsy-hardware.git\">Git link<\/a>.<\/p>\n<p><a href=\"https:\/\/github.com\/1Bitsy\/1bitsy-hardware\/blob\/master\/doc\/1bitsy_v1_0d_legend.png?raw=true\">Pinouts<\/a> (<a href=\"https:\/\/github.com\/1Bitsy\/1bitsy-hardware\/blob\/master\/doc\/1bitsy_v1_0d_legend.png\">GitHub view<\/a>)<\/p>\n<h2>Appendix C: Microcontroller STM32F415<\/h2>\n<p>The one on the 1Bitsy is:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.st.com\/en\/microcontrollers-microprocessors\/stm32f415rg.html\">STM32F415RGT6<\/a><\/li>\n<li>STM32F415 32 bit 168 MHz<\/li>\n<li>ARM Cortex-M4F<\/li>\n<li>192 KB RAM<\/li>\n<li>1 MB Flash<\/li>\n<li>AES hardware acceleration<\/li>\n<\/ul>\n<h2>Appendix D: Forth system <em>Mecrisp Stellaris<\/em><\/h2>\n<p><a href=\"https:\/\/github.com\/PeterMortensen\/mecrisp-stellaris.git\">GitHub page<\/a>. Direct <a href=\"https:\/\/github.com\/PeterMortensen\/mecrisp-stellaris.git\">Git link<\/a>.<\/p>\n<h2>References<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=bmtOyr7UYNo\"><em>STM32 Tutorial #49 &#8211; HOWTO CAN filters in detail<\/em><\/a> (21 minutes). This video doesn&#8217;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, <a href=\"https:\/\/www.youtube.com\/watch?v=RrR-BDoBoSg\"><em>STM32 Tutorial Videos #48 &#8211; HOWTO use CAN<\/em><\/a>. And <a href=\"https:\/\/stm32world.com\/wiki\/STM32_Tutorial_Videos\">this list of the videos<\/a> on <a href=\"https:\/\/stm32world.com\/wiki\/Main_Page\">STM32World Wiki<\/a>.<\/li>\n<li><em><a href=\"https:\/\/stackoverflow.com\/questions\/42614223\/\">STM32F4 &#8211; CAN bus transmit succeeds every time, but CAN receive only succeeds on the first call<\/a><\/em>. It has <em>&#8220;&#8230;in order to enable CAN2, CAN1 needs to be enabled&#8221;<\/em>. This reference was found retrospectively.<\/li>\n<\/ul>\n<p><!-- \nRef: ID 11490. <\/home\/mortensen\/temp2\/2023-04-17\/Embedded day, 2021-09-27, ID 11490.txt>\n--><\/p>\n<p><!-- The end. Marker for editing in WordPress: pppp --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The short version: The CAN bus 2 channel on ARM microcontrollers only works if CAN 1 is also set up&#8230; That is, CAN 2 can not be set up independently; for it to work at all, the other CAN channel, &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/pmortensen.eu\/world2\/2023\/04\/17\/gotcha-using-can-2-on-arm-microcontrollers-stm32f415-1bitsy\/\"> <span class=\"screen-reader-text\">Gotcha using CAN 2 on ARM microcontrollers (e.g., STM32F415 on 1Bitsy)<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[34,31,4,33],"tags":[],"_links":{"self":[{"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/posts\/3579"}],"collection":[{"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/comments?post=3579"}],"version-history":[{"count":23,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/posts\/3579\/revisions"}],"predecessor-version":[{"id":5984,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/posts\/3579\/revisions\/5984"}],"wp:attachment":[{"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/media?parent=3579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/categories?post=3579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/tags?post=3579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}