<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[M5StampS3 &#x2F; M5Dial and CAN]]></title><description><![CDATA[<p dir="auto">Has anyone got the CAN unit to work with the ESP32 S3 devices?</p>
<p dir="auto">I end up with a load of compiled messages when I try using the ported Atom examples using Platformio</p>
<p dir="auto">It looks like the problem is in CAN.c and the TWAI driver<br />
see<br />
<a href="https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/twai.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/twai.html</a></p>
<p dir="auto">Error Messages<br />
"In file included from C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_reg.h:21,<br />
from src/CAN.c:38:<br />
src/CAN.c: In function 'CAN_init':<br />
src/CAN.c:169:29: error: 'DPORT_PERIP_CLK_EN_REG' undeclared (first use in this function); did<br />
you mean 'SYSTEM_PERIP_CLK_EN1_REG'?<br />
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);<br />
^~~~~~~~~~~~~~~~~~~~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:75:67: note: in definition of macro '_DPORT_WRITE_PERI_REG'<br />
#define _DPORT_WRITE_PERI_REG(addr, val) (*((volatile uint32_t <em>)(addr))) = (uint32_t)(val)<br />
^~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:88:46: note: in expansion of macro 'DPORT_WRITE_PERI_REG'<br />
#define DPORT_SET_PERI_REG_MASK(reg, mask)   DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)|(mask)))<br />
^~~~~~~~~~~~~~~~~~~~<br />
src/CAN.c:169:5: note: in expansion of macro 'DPORT_SET_PERI_REG_MASK'<br />
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);<br />
^~~~~~~~~~~~~~~~~~~~~~~<br />
src/CAN.c:169:29: note: each undeclared identifier is reported only once for each function it appears in<br />
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);<br />
^~~~~~~~~~~~~~~~~~~~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:75:67: note: in definition of macro '_DPORT_WRITE_PERI_REG'<br />
#define _DPORT_WRITE_PERI_REG(addr, val) (</em>((volatile uint32_t <em>)(addr))) = (uint32_t)(val)<br />
^~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:88:46: note: in expansion of macro 'DPORT_WRITE_PERI_REG'<br />
#define DPORT_SET_PERI_REG_MASK(reg, mask)   DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)|(mask)))<br />
^~~~~~~~~~~~~~~~~~~~<br />
src/CAN.c:169:5: note: in expansion of macro 'DPORT_SET_PERI_REG_MASK'<br />
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);<br />
^~~~~~~~~~~~~~~~~~~~~~~<br />
src/CAN.c:169:53: error: 'DPORT_CAN_CLK_EN' undeclared (first use in this function); did you mean 'DPORT_REG_CLR_BIT'?<br />
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);<br />
^~~~~~~~~~~~~~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:75:88: note: in definition of macro '_DPORT_WRITE_PERI_REG'<br />
#define _DPORT_WRITE_PERI_REG(addr, val) (</em>((volatile uint32_t <em>)(addr))) = (uint32_t)(val)<br />
^~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:88:46: note: in expansion of macro 'DPORT_WRITE_PERI_REG'<br />
#define DPORT_SET_PERI_REG_MASK(reg, mask)   DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)|(mask)))<br />
^~~~~~~~~~~~~~~~~~~~<br />
src/CAN.c:169:5: note: in expansion of macro 'DPORT_SET_PERI_REG_MASK'<br />
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);<br />
^~~~~~~~~~~~~~~~~~~~~~~<br />
src/CAN.c:170:31: error: 'DPORT_PERIP_RST_EN_REG' undeclared (first use in this function); did<br />
you mean 'SYSTEM_PERIP_RST_EN0_REG'?<br />
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST);<br />
^~~~~~~~~~~~~~~~~~~~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:75:67: note: in definition of macro '_DPORT_WRITE_PERI_REG'<br />
#define _DPORT_WRITE_PERI_REG(addr, val) (</em>((volatile uint32_t <em>)(addr))) = (uint32_t)(val)<br />
^~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:85:46: note: in expansion of macro 'DPORT_WRITE_PERI_REG'<br />
#define DPORT_CLEAR_PERI_REG_MASK(reg, mask) DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)&amp;(~(mask))))<br />
^~~~~~~~~~~~~~~~~~~~<br />
src/CAN.c:170:5: note: in expansion of macro 'DPORT_CLEAR_PERI_REG_MASK'<br />
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST);<br />
^~~~~~~~~~~~~~~~~~~~~~~~~<br />
src/CAN.c:170:55: error: 'DPORT_CAN_RST' undeclared (first use in this function); did you mean<br />
'DPORT_DATE_REG'?<br />
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST);<br />
^~~~~~~~~~~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:75:88: note: in definition of macro '_DPORT_WRITE_PERI_REG'<br />
#define _DPORT_WRITE_PERI_REG(addr, val) (</em>((volatile uint32_t <em>)(addr))) = (uint32_t)(val)<br />
^~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:85:46: note: in expansion of macro 'DPORT_WRITE_PERI_REG'<br />
#define DPORT_CLEAR_PERI_REG_MASK(reg, mask) DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)&amp;(~(mask))))<br />
^~~~~~~~~~~~~~~~~~~~<br />
src/CAN.c:170:5: note: in expansion of macro 'DPORT_CLEAR_PERI_REG_MASK'<br />
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST);<br />
^~~~~~~~~~~~~~~~~~~~~~~~~<br />
src/CAN.c:175:40: error: 'CAN_TX_IDX' undeclared (first use in this function); did you mean 'TWAI_TX_IDX'?<br />
gpio_matrix_out(CAN_cfg.tx_pin_id, CAN_TX_IDX, 0, 0);<br />
^~~~~~~~~~<br />
TWAI_TX_IDX<br />
src/CAN.c:180:39: error: 'CAN_RX_IDX' undeclared (first use in this function); did you mean 'TWAI_RX_IDX'?<br />
gpio_matrix_in(CAN_cfg.rx_pin_id, CAN_RX_IDX, 0);<br />
^~~~~~~~~~<br />
TWAI_RX_IDX<br />
src/CAN.c:252:20: error: 'ETS_CAN_INTR_SOURCE' undeclared (first use in this function)<br />
esp_intr_alloc(ETS_CAN_INTR_SOURCE, 0, CAN_isr, NULL, NULL);<br />
^~~~~~~~~~~~~~~~~~~<br />
Compiling .pio\build\m5stack-stamps3\src\main.cpp.o<br />
Compiling .pio\build\m5stack-stamps3\lib421\ESP32CAN\CAN.c.o<br />
In file included from .pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c:37:<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/esp_hw_support/include/esp_intr.h:8:2: warning: #warning esp_intr.h is deprecated, please include esp_intr_alloc.h instead [-Wcpp]<br />
#warning esp_intr.h is deprecated, please include esp_intr_alloc.h instead<br />
^~~~~~~<br />
In file included from C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_reg.h:21,<br />
from .pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c:38:<br />
.pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c: In function 'CAN_init':<br />
.pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c:173:26: error: 'DPORT_PERIP_CLK_EN_REG' undeclared (first use in this function); did you mean 'SYSTEM_PERIP_CLK_EN1_REG'?<br />
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);<br />
^~~~~~~~~~~~~~~~~~~~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:75:67: note: in definition of macro '_DPORT_WRITE_PERI_REG'<br />
#define _DPORT_WRITE_PERI_REG(addr, val) (</em>((volatile uint32_t <em>)(addr))) = (uint32_t)(val)<br />
^~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:88:46: note: in expansion of macro 'DPORT_WRITE_PERI_REG'<br />
#define DPORT_SET_PERI_REG_MASK(reg, mask)   DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)|(mask)))<br />
^~~~~~~~~~~~~~~~~~~~<br />
.pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c:173:2: note: in expansion of macro 'DPORT_SET_PERI_REG_MASK'<br />
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);<br />
^~~~~~~~~~~~~~~~~~~~~~~<br />
.pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c:173:26: note: each undeclared identifier is reported only once for each function it appears in<br />
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);<br />
^~~~~~~~~~~~~~~~~~~~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:75:67: note: in definition of macro '_DPORT_WRITE_PERI_REG'<br />
#define _DPORT_WRITE_PERI_REG(addr, val) (</em>((volatile uint32_t <em>)(addr))) = (uint32_t)(val)<br />
^~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:88:46: note: in expansion of macro 'DPORT_WRITE_PERI_REG'<br />
#define DPORT_SET_PERI_REG_MASK(reg, mask)   DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)|(mask)))<br />
^~~~~~~~~~~~~~~~~~~~<br />
.pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c:173:2: note: in expansion of macro 'DPORT_SET_PERI_REG_MASK'<br />
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);<br />
^~~~~~~~~~~~~~~~~~~~~~~<br />
.pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c:173:50: error: 'DPORT_CAN_CLK_EN' undeclared (first use in this function); did you mean 'DPORT_REG_CLR_BIT'?<br />
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);<br />
^~~~~~~~~~~~~~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:75:88: note: in definition of macro '_DPORT_WRITE_PERI_REG'<br />
#define _DPORT_WRITE_PERI_REG(addr, val) (</em>((volatile uint32_t <em>)(addr))) = (uint32_t)(val)<br />
^~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:88:46: note: in expansion of macro 'DPORT_WRITE_PERI_REG'<br />
#define DPORT_SET_PERI_REG_MASK(reg, mask)   DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)|(mask)))<br />
^~~~~~~~~~~~~~~~~~~~<br />
.pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c:173:2: note: in expansion of macro 'DPORT_SET_PERI_REG_MASK'<br />
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);<br />
^~~~~~~~~~~~~~~~~~~~~~~<br />
.pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c:174:28: error: 'DPORT_PERIP_RST_EN_REG' undeclared (first use in this function); did you mean 'SYSTEM_PERIP_RST_EN0_REG'?<br />
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST);<br />
^~~~~~~~~~~~~~~~~~~~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:75:67: note: in definition of macro '_DPORT_WRITE_PERI_REG'<br />
#define _DPORT_WRITE_PERI_REG(addr, val) (</em>((volatile uint32_t <em>)(addr))) = (uint32_t)(val)<br />
^~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:85:46: note: in expansion of macro 'DPORT_WRITE_PERI_REG'<br />
#define DPORT_CLEAR_PERI_REG_MASK(reg, mask) DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)&amp;(~(mask))))<br />
^~~~~~~~~~~~~~~~~~~~<br />
.pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c:174:2: note: in expansion of macro 'DPORT_CLEAR_PERI_REG_MASK'<br />
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST);<br />
^~~~~~~~~~~~~~~~~~~~~~~~~<br />
.pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c:174:52: error: 'DPORT_CAN_RST' undeclared (first use in this function); did you mean 'DPORT_DATE_REG'?<br />
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST);<br />
^~~~~~~~~~~~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:75:88: note: in definition of macro '_DPORT_WRITE_PERI_REG'<br />
#define _DPORT_WRITE_PERI_REG(addr, val) (</em>((volatile uint32_t *)(addr))) = (uint32_t)(val)<br />
^~~<br />
C:/Users/simon/.platformio/packages/framework-arduinoespressif32@src-e2e946657dbcd16e4aabb8a644a06175/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_access.h:85:46: note: in expansion of macro 'DPORT_WRITE_PERI_REG'<br />
#define DPORT_CLEAR_PERI_REG_MASK(reg, mask) DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)&amp;(~(mask))))<br />
^~~~~~~~~~~~~~~~~~~~<br />
.pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c:174:2: note: in expansion of macro 'DPORT_CLEAR_PERI_REG_MASK'<br />
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST);<br />
^~~~~~~~~~~~~~~~~~~~~~~~~<br />
.pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c:179:37: error: 'CAN_TX_IDX' undeclared (first use in this function); did you mean 'TWAI_TX_IDX'?<br />
gpio_matrix_out(CAN_cfg.tx_pin_id, CAN_TX_IDX, 0, 0);<br />
^~~~~~~~~~<br />
TWAI_TX_IDX<br />
.pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c:184:36: error: 'CAN_RX_IDX' undeclared (first use in this function); did you mean 'TWAI_RX_IDX'?<br />
gpio_matrix_in(CAN_cfg.rx_pin_id, CAN_RX_IDX, 0);<br />
^~~~~~~~~~<br />
TWAI_RX_IDX<br />
.pio/libdeps/m5stack-stamps3/ESP32CAN/src/CAN.c:254:17: error: 'ETS_CAN_INTR_SOURCE' undeclared (first use in this function)<br />
esp_intr_alloc(ETS_CAN_INTR_SOURCE, 0, CAN_isr, NULL, NULL);<br />
^~~~~~~~~~~~~~~~~~~<br />
*** [.pio\build\m5stack-stamps3\src\CAN.c.o] Error 1<br />
*** [.pio\build\m5stack-stamps3\lib421\ESP32CAN\CAN.c.o] Error 1<br />
================================= [FAILED] Took 16.27 seconds ================================="</p>
<p dir="auto">Source code<br />
"<br />
/**</p>
<ul>
<li>@file encoder.ino</li>
<li>@author SeanKwok (<a href="mailto:shaoxiang@m5stack.com" target="_blank" rel="noopener noreferrer nofollow ugc">shaoxiang@m5stack.com</a>)</li>
<li><a class="plugin-mentions-user plugin-mentions-a" href="/user/brief" aria-label="Profile: brief">@<bdi>brief</bdi></a> M5Dial Encoder Test</li>
<li>@version 0.2</li>
<li>@date 2023-10-18</li>
<li></li>
<li></li>
<li>@Hardwares: M5Dial</li>
<li><a href="https://shop.m5stack.com/products/m5stack-dial-esp32-s3-smart-rotary-knob-w-1-28-round-touch-screen" target="_blank" rel="noopener noreferrer nofollow ugc">https://shop.m5stack.com/products/m5stack-dial-esp32-s3-smart-rotary-knob-w-1-28-round-touch-screen</a></li>
<li><a href="https://docs.m5stack.com/en/core/M5Dial" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.m5stack.com/en/core/M5Dial</a></li>
<li><a href="https://github.com/m5stack/M5Dial" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5Dial</a></li>
<li></li>
<li><a class="plugin-mentions-user plugin-mentions-a" href="/user/platform" aria-label="Profile: Platform">@<bdi>Platform</bdi></a> Version: Arduino M5Stack Board Manager v2.0.7</li>
<li>@Dependent Library:</li>
<li>M5GFX: <a href="https://github.com/m5stack/M5GFX" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5GFX</a></li>
<li>M5Unified: <a href="https://github.com/m5stack/M5Unified" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5Unified</a></li>
<li></li>
<li>CANBus Unit(CA-IS3050G) Grove cable connected</li>
<li><a href="https://shop.m5stack.com/products/canbus-unitca-is3050g" target="_blank" rel="noopener noreferrer nofollow ugc">https://shop.m5stack.com/products/canbus-unitca-is3050g</a></li>
<li><a href="https://docs.m5stack.com/en/unit/can?ref=kmjp2x8a" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.m5stack.com/en/unit/can?ref=kmjp2x8a</a></li>
<li><a href="https://github.com/m5stack/M5Stack/tree/master/examples/Unit/CAN" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5Stack/tree/master/examples/Unit/CAN</a></li>
<li></li>
</ul>
<p dir="auto">*/</p>
<p dir="auto">#include "M5Dial.h"<br />
#include &lt;M5Unified.h&gt;<br />
#include &lt;M5GFX.h&gt;<br />
#include &lt;ESP32CAN.h&gt;<br />
#include &lt;CAN_config.h&gt;<br />
#include "driver/twai.h"</p>
<p dir="auto">/****** comment out to make sender ********/<br />
#define CAN_RECIEVER  // Remove to make sender</p>
<p dir="auto">#define Use_PortB  // Remove to use Port A (Red)</p>
<p dir="auto">#define CAN_MSG_ID 0x001</p>
<p dir="auto">CAN_device_t CAN_cfg;              // CAN Config.<br />
unsigned long previousMillis = 0;  // will store last time a CAN Message was sent                                // send.  将存储上次发送CAN消息的时间。<br />
const int interval = 80;           // interval at which send CAN Messages (milliseconds).</p>
<p dir="auto">const int rx_queue_size = 10;  // Receive Queue size.<br />
int LedNumberCount      = 0;<br />
int waitCANData         = 0;</p>
<p dir="auto">uint8_t msgcnt = 0;</p>
<p dir="auto">void setup()<br />
{</p>
<pre><code>auto cfg = M5.config();
M5Dial.begin(cfg, true, false);

M5Dial.Display.setTextColor(GREEN);
M5Dial.Display.setTextDatum(middle_center);
M5Dial.Display.setFont(&amp;fonts::Orbitron_Light_32);
M5Dial.Display.setTextSize(1);
        M5Dial.Display.drawString(String("Dial CAN"), M5Dial.Display.width() / 2, M5Dial.Display.height() / 2);

M5.Lcd.println("M5Stack Core2 and CAN Bus adaptor");  // Print a string on the screen.
 
M5.Lcd.setTextColor(ORANGE);
</code></pre>
<p dir="auto">// M5.Lcd.println("*  sending a string to be converted to upper case,  <em>");<br />
// M5.Lcd.println("</em>  receiving response and display it on Terminal.   *");</p>
<pre><code>Serial.println("Basic Demo - ESP32-Arduino-CAN");
Serial.println("M5Stack CoreS3 and CAN Bus adaptor");
Serial.println("*  sending a string to be converted to upper case,  *");
Serial.println("*  receiving response and display it on a Terminal. *");

/* set CAN pins */
// GROVE connector GPIO pins    
</code></pre>
<p dir="auto">#ifdef Use_PortB<br />
// Port B<br />
CAN_cfg.tx_pin_id = GPIO_NUM_1;  //<br />
CAN_cfg.rx_pin_id = GPIO_NUM_2;<br />
#else<br />
// Port A Red Port (Shared with I2C)<br />
CAN_cfg.tx_pin_id = GPIO_NUM_15;  // SCL<br />
CAN_cfg.rx_pin_id = GPIO_NUM_13;  // SDA<br />
#endif</p>
<pre><code>CAN_cfg.speed = CAN_SPEED_500KBPS;

CAN_cfg.rx_queue  = xQueueCreate(rx_queue_size, sizeof(CAN_frame_t));

ESP32Can.CANInit();
Serial.println("CAN Installed");
</code></pre>
<p dir="auto">#ifdef CAN_RECIEVER<br />
Serial.println("Set as RECIEVER");<br />
<a href="//M5.Lcd.println" target="_blank" rel="noopener noreferrer nofollow ugc">//M5.Lcd.println</a>("*  Set as RECIEVER  <em>");<br />
#else<br />
Serial.println("Set as SENDER");<br />
M5.Lcd.println("</em>  Set as SENDER  *");<br />
#endif</p>
<p dir="auto">}</p>
<p dir="auto">void loop()<br />
{<br />
unsigned long currentMillis = millis();</p>
<p dir="auto">#ifdef CAN_RECIEVER</p>
<pre><code>// recieve CAN Message
CAN_frame_t rx_frame;

if (xQueueReceive(CAN_cfg.rx_queue, &amp;rx_frame, 3 * portTICK_PERIOD_MS) ==  pdTRUE) 
{
    if (rx_frame.FIR.B.FF == CAN_frame_std) 
    {
        Serial.printf("New standard frame");
    } 
    else
    {
        Serial.printf("New extended frame");
    }

    if (rx_frame.FIR.B.RTR == CAN_RTR) 
    {
        Serial.printf(" RTR from 0x%08X, DLC %d\r\n", rx_frame.MsgID, rx_frame.FIR.B.DLC);
    }
    else
    {
        Serial.printf(" from 0x%08X, DLC %d, Data ", rx_frame.MsgID, rx_frame.FIR.B.DLC);
        for (int i = 0; i &lt; rx_frame.FIR.B.DLC; i++) 
        {
            Serial.printf("0x%02X ", rx_frame.data.u8[i]);
        }
        Serial.printf("\n");
        if (rx_frame.data.u8[0] == 0x01) 
        {
            CAN_frame_t tx_frame;
            tx_frame.FIR.B.FF   = CAN_frame_std;
            tx_frame.MsgID      = CAN_MSG_ID;
            tx_frame.FIR.B.DLC  = 8;
            tx_frame.data.u8[0] = 0x02;
            tx_frame.data.u8[1] = rx_frame.data.u8[1];
            tx_frame.data.u8[2] = 0x00;
            tx_frame.data.u8[3] = 0x00;
            tx_frame.data.u8[4] = 0x00;
            tx_frame.data.u8[5] = 0x00;
            tx_frame.data.u8[6] = 0x00;
            tx_frame.data.u8[7] = 0x00;
            ESP32Can.CANWriteFrame(&amp;tx_frame);
        }
    }
}
</code></pre>
<p dir="auto">#else<br />
// Send CAN Message<br />
if (currentMillis - previousMillis &gt;= interval)<br />
{<br />
ESP32Can.CANInit();<br />
previousMillis = currentMillis;<br />
CAN_frame_t tx_frame;<br />
tx_frame.FIR.B.FF   = CAN_frame_std;<br />
tx_frame.MsgID      = CAN_MSG_ID;<br />
tx_frame.FIR.B.DLC  = 8;<br />
tx_frame.data.u8[0] = 0x01;<br />
tx_frame.data.u8[1] = msgcnt;<br />
tx_frame.data.u8[2] = 0x00;<br />
tx_frame.data.u8[3] = 0x00;<br />
tx_frame.data.u8[4] = 0x00;<br />
tx_frame.data.u8[5] = 0x00;<br />
tx_frame.data.u8[6] = 0x00;<br />
tx_frame.data.u8[7] = 0x00;</p>
<pre><code>    ESP32Can.CANWriteFrame(&amp;tx_frame);
     ESP32Can.CANStop();
    msgcnt++;
    if (msgcnt &gt; 29) 
    {
        msgcnt = 0;
    }
}

CAN_frame_t rx_frame;

if (xQueueReceive(CAN_cfg.rx_queue, &amp;rx_frame, 3 * portTICK_PERIOD_MS) == pdTRUE) 
{
    if (rx_frame.FIR.B.FF == CAN_frame_std) 
    {
        Serial.printf("New standard frame");
    } 
    else 
    {
        Serial.printf("New extended frame");
    }

    if (rx_frame.FIR.B.RTR == CAN_RTR) 
    {
        Serial.printf(" RTR from 0x%08X, DLC %d\r\n", rx_frame.MsgID, rx_frame.FIR.B.DLC);
    } 
    else 
    {
        Serial.printf(" from 0x%08X, DLC %d, Data ", rx_frame.MsgID, rx_frame.FIR.B.DLC);

        for (int i = 0; i &lt; rx_frame.FIR.B.DLC; i++) 
        {
            Serial.printf("0x%02X ", rx_frame.data.u8[i]);
        }
        Serial.printf("\n");

        if (rx_frame.data.u8[0] == 0x02) 
        {
                if (rx_frame.data.u8[1] &lt; 25)
            {
                Serial.println("x");
                //M5.dis.drawpix(rx_frame.data.u8[1], CRGB(100, 0, 0));
            } 
            else if (rx_frame.data.u8[1] &gt; 27) 
            {
                Serial.println("y");
                //M5.dis.fillpix(CRGB(0, 0, 20));
            }
            waitCANData = 0;
        }
    }
}
</code></pre>
<p dir="auto">#endif<br />
// waitCANData<br />
M5.update();<br />
if (M5.BtnA.isPressed())<br />
{<br />
M5.Lcd.fillScreen(YELLOW);<br />
esp_restart();<br />
}<br />
delay(10);<br />
}<br />
"</p>
<p dir="auto">Platformio.ini</p>
<p dir="auto">"<br />
; PlatformIO Project Configuration File<br />
;<br />
;   Build options: build flags, source filter<br />
;   Upload options: custom upload port, speed and extra flags<br />
;   Library options: dependencies, extra library storages<br />
;   Advanced options: extra scripting<br />
;<br />
; Please visit documentation for the other options and examples<br />
; <a href="https://docs.platformio.org/page/projectconf.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.platformio.org/page/projectconf.html</a></p>
<p dir="auto">[env:m5stack-stamps3]<br />
platform = espressif32<br />
board = m5stack-stamps3<br />
framework = arduino<br />
lib_deps =<br />
m5stack/M5Dial@^1.0.2<br />
m5stack/M5Unified@^0.1.11<br />
m5stack/M5GFX@^0.1.11<br />
miwagner/ESP32CAN@^0.0.1<br />
platform_packages = framework-arduinoespressif32@<a href="https://github.com/espressif/arduino-esp32/archive/refs/tags/2.0.14.zip" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/espressif/arduino-esp32/archive/refs/tags/2.0.14.zip</a><br />
lib_ldf_mode = deep+<br />
upload_speed = 1500000<br />
upload_port = COM7<br />
monitor_speed = 115200<br />
monitor_port = COM7<br />
"</p>
]]></description><link>https://community.m5stack.com/topic/5888/m5stamps3-m5dial-and-can</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Apr 2026 09:48:11 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/5888.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 14 Dec 2023 10:36:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to M5StampS3 &#x2F; M5Dial and CAN on Thu, 14 Dec 2023 20:15:56 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/samarkh" aria-label="Profile: samarkh">@<bdi>samarkh</bdi></a></p>
<p dir="auto">sorry, no idea when and if such a library will be developed.</p>
<p dir="auto">That said, maybe this <a href="https://github.com/espressif/arduino-esp32/tree/master/libraries/ESP32/examples/TWAI" target="_blank" rel="noopener noreferrer nofollow ugc">example</a> helps?</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/23046</link><guid isPermaLink="true">https://community.m5stack.com/post/23046</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Thu, 14 Dec 2023 20:15:56 GMT</pubDate></item><item><title><![CDATA[Reply to M5StampS3 &#x2F; M5Dial and CAN on Thu, 14 Dec 2023 17:12:43 GMT]]></title><description><![CDATA[<p dir="auto">Hi Felix<br />
Do you know if there is any plan to develop/recommend one as the M5Dial is perfect for Automotive applications?</p>
<p dir="auto">Yours Simon M.</p>
]]></description><link>https://community.m5stack.com/post/23045</link><guid isPermaLink="true">https://community.m5stack.com/post/23045</guid><dc:creator><![CDATA[samarkh]]></dc:creator><pubDate>Thu, 14 Dec 2023 17:12:43 GMT</pubDate></item><item><title><![CDATA[Reply to M5StampS3 &#x2F; M5Dial and CAN on Thu, 14 Dec 2023 14:39:46 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/samarkh" aria-label="Profile: samarkh">@<bdi>samarkh</bdi></a></p>
<p dir="auto">it looks like the CAN library is not compatible with the S3 variant used in M5Dial. See <a href="https://community.platformio.org/t/can-h-on-esp32-with-arduino-framework-not-working/30815/3" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/23042</link><guid isPermaLink="true">https://community.m5stack.com/post/23042</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Thu, 14 Dec 2023 14:39:46 GMT</pubDate></item></channel></rss>