M5 Dial V1.1 CAN bus
-
I am trying to use a Dial with an Isolated CAN bus unit connected to port a, to read CAN Messages.
I'm using Arduino IDE 2.3.5 but I'm getting these compile errors.
In file included from C:\Users\DavidYoder\AppData\Local\Arduino15\packages\m5stack\tools\esp32-arduino-libs\idf-release_v5.4-2f7dcd86-v1\esp32s3/include/soc/esp32s3/include/soc/dport_reg.h:20,
from c:\Users\DavidYoder\Documents\Arduino\Sketchbook\libraries\ESP32CAN\src\CAN.c:38:
c:\Users\DavidYoder\Documents\Arduino\Sketchbook\libraries\ESP32CAN\src\CAN.c: In function 'CAN_init':
c:\Users\DavidYoder\Documents\Arduino\Sketchbook\libraries\ESP32CAN\src\CAN.c:173:33: error: 'DPORT_PERIP_CLK_EN_REG' undeclared (first use in this function); did you mean 'SYSTEM_PERIP_CLK_EN1_REG'?
173 | DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);
| ^~~~~~~~~~~~~~~~~~~~~~
C:\Users\DavidYoder\AppData\Local\Arduino15\packages\m5stack\tools\esp32-arduino-libs\idf-release_v5.4-2f7dcd86-v1\esp32s3/include/soc/esp32s3/include/soc/dport_access.h:77:67: note: in definition of macro '_DPORT_WRITE_PERI_REG'
77 | #define _DPORT_WRITE_PERI_REG(addr, val) (*((volatile uint32_t )(addr))) = (uint32_t)(val)
| ^~~~
C:\Users\DavidYoder\AppData\Local\Arduino15\packages\m5stack\tools\esp32-arduino-libs\idf-release_v5.4-2f7dcd86-v1\esp32s3/include/soc/esp32s3/include/soc/dport_access.h:90:46: note: in expansion of macro 'DPORT_WRITE_PERI_REG'
90 | #define DPORT_SET_PERI_REG_MASK(reg, mask) DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)|(mask)))
| ^~~~~~~~~~~~~~~~~~~~
c:\Users\DavidYoder\Documents\Arduino\Sketchbook\libraries\ESP32CAN\src\CAN.c:173:9: note: in expansion of macro 'DPORT_SET_PERI_REG_MASK'
173 | DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);
| ^~~~~~~~~~~~~~~~~~~~~~~
c:\Users\DavidYoder\Documents\Arduino\Sketchbook\libraries\ESP32CAN\src\CAN.c:173:33: note: each undeclared identifier is reported only once for each function it appears in
173 | DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);
| ^~~~~~~~~~~~~~~~~~~~~~
C:\Users\DavidYoder\AppData\Local\Arduino15\packages\m5stack\tools\esp32-arduino-libs\idf-release_v5.4-2f7dcd86-v1\esp32s3/include/soc/esp32s3/include/soc/dport_access.h:77:67: note: in definition of macro '_DPORT_WRITE_PERI_REG'
77 | #define _DPORT_WRITE_PERI_REG(addr, val) (((volatile uint32_t )(addr))) = (uint32_t)(val)
| ^~~~
C:\Users\DavidYoder\AppData\Local\Arduino15\packages\m5stack\tools\esp32-arduino-libs\idf-release_v5.4-2f7dcd86-v1\esp32s3/include/soc/esp32s3/include/soc/dport_access.h:90:46: note: in expansion of macro 'DPORT_WRITE_PERI_REG'
90 | #define DPORT_SET_PERI_REG_MASK(reg, mask) DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)|(mask)))
| ^~~~~~~~~~~~~~~~~~~~
c:\Users\DavidYoder\Documents\Arduino\Sketchbook\libraries\ESP32CAN\src\CAN.c:173:9: note: in expansion of macro 'DPORT_SET_PERI_REG_MASK'
173 | DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);
| ^~~~~~~~~~~~~~~~~~~~~~~
c:\Users\DavidYoder\Documents\Arduino\Sketchbook\libraries\ESP32CAN\src\CAN.c:173:57: error: 'DPORT_CAN_CLK_EN' undeclared (first use in this function)
173 | DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);
| ^~~~~~~~~~~~~~~~
C:\Users\DavidYoder\AppData\Local\Arduino15\packages\m5stack\tools\esp32-arduino-libs\idf-release_v5.4-2f7dcd86-v1\esp32s3/include/soc/esp32s3/include/soc/dport_access.h:77:88: note: in definition of macro '_DPORT_WRITE_PERI_REG'
77 | #define _DPORT_WRITE_PERI_REG(addr, val) (((volatile uint32_t )(addr))) = (uint32_t)(val)
| ^~~
C:\Users\DavidYoder\AppData\Local\Arduino15\packages\m5stack\tools\esp32-arduino-libs\idf-release_v5.4-2f7dcd86-v1\esp32s3/include/soc/esp32s3/include/soc/dport_access.h:90:46: note: in expansion of macro 'DPORT_WRITE_PERI_REG'
90 | #define DPORT_SET_PERI_REG_MASK(reg, mask) DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)|(mask)))
| ^~~~~~~~~~~~~~~~~~~~
c:\Users\DavidYoder\Documents\Arduino\Sketchbook\libraries\ESP32CAN\src\CAN.c:173:9: note: in expansion of macro 'DPORT_SET_PERI_REG_MASK'
173 | DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);
| ^~~~~~~~~~~~~~~~~~~~~~~
c:\Users\DavidYoder\Documents\Arduino\Sketchbook\libraries\ESP32CAN\src\CAN.c:174:35: error: 'DPORT_PERIP_RST_EN_REG' undeclared (first use in this function); did you mean 'SYSTEM_PERIP_RST_EN0_REG'?
174 | DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST);
| ^~~~~~~~~~~~~~~~~~~~~~
C:\Users\DavidYoder\AppData\Local\Arduino15\packages\m5stack\tools\esp32-arduino-libs\idf-release_v5.4-2f7dcd86-v1\esp32s3/include/soc/esp32s3/include/soc/dport_access.h:77:67: note: in definition of macro '_DPORT_WRITE_PERI_REG'
77 | #define _DPORT_WRITE_PERI_REG(addr, val) (((volatile uint32_t )(addr))) = (uint32_t)(val)
| ^~~~
C:\Users\DavidYoder\AppData\Local\Arduino15\packages\m5stack\tools\esp32-arduino-libs\idf-release_v5.4-2f7dcd86-v1\esp32s3/include/soc/esp32s3/include/soc/dport_access.h:87:46: note: in expansion of macro 'DPORT_WRITE_PERI_REG'
87 | #define DPORT_CLEAR_PERI_REG_MASK(reg, mask) DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)&(~(mask))))
| ^~~~~~~~~~~~~~~~~~~~
c:\Users\DavidYoder\Documents\Arduino\Sketchbook\libraries\ESP32CAN\src\CAN.c:174:9: note: in expansion of macro 'DPORT_CLEAR_PERI_REG_MASK'
174 | DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
c:\Users\DavidYoder\Documents\Arduino\Sketchbook\libraries\ESP32CAN\src\CAN.c:174:59: error: 'DPORT_CAN_RST' undeclared (first use in this function)
174 | DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST);
| ^~~~~~~~~~~~~
C:\Users\DavidYoder\AppData\Local\Arduino15\packages\m5stack\tools\esp32-arduino-libs\idf-release_v5.4-2f7dcd86-v1\esp32s3/include/soc/esp32s3/include/soc/dport_access.h:77:88: note: in definition of macro '_DPORT_WRITE_PERI_REG'
77 | #define _DPORT_WRITE_PERI_REG(addr, val) (((volatile uint32_t *)(addr))) = (uint32_t)(val)
| ^~~
C:\Users\DavidYoder\AppData\Local\Arduino15\packages\m5stack\tools\esp32-arduino-libs\idf-release_v5.4-2f7dcd86-v1\esp32s3/include/soc/esp32s3/include/soc/dport_access.h:87:46: note: in expansion of macro 'DPORT_WRITE_PERI_REG'
87 | #define DPORT_CLEAR_PERI_REG_MASK(reg, mask) DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)&(~(mask))))
| ^~~~~~~~~~~~~~~~~~~~
c:\Users\DavidYoder\Documents\Arduino\Sketchbook\libraries\ESP32CAN\src\CAN.c:174:9: note: in expansion of macro 'DPORT_CLEAR_PERI_REG_MASK'
174 | DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
c:\Users\DavidYoder\Documents\Arduino\Sketchbook\libraries\ESP32CAN\src\CAN.c:179:44: error: 'CAN_TX_IDX' undeclared (first use in this function)
179 | gpio_matrix_out(CAN_cfg.tx_pin_id, CAN_TX_IDX, 0, 0);
| ^~~~~~~~~~
c:\Users\DavidYoder\Documents\Arduino\Sketchbook\libraries\ESP32CAN\src\CAN.c:184:43: error: 'CAN_RX_IDX' undeclared (first use in this function)
184 | gpio_matrix_in(CAN_cfg.rx_pin_id, CAN_RX_IDX, 0);
| ^~~~~~~~~~
c:\Users\DavidYoder\Documents\Arduino\Sketchbook\libraries\ESP32CAN\src\CAN.c:254:24: error: 'ETS_CAN_INTR_SOURCE' undeclared (first use in this function)
254 | esp_intr_alloc(ETS_CAN_INTR_SOURCE, 0, CAN_isr, NULL, NULL);
| ^~~~~~~~~~~~~~~~~~~
exit status 1Compilation error: exit status 1
-
@davidrubixbattery
The compilation errors you're encountering are related to the ESP32CAN library in the Arduino IDE. Specifically, the errors indicate that certain registers and definitions (DPORT_PERIP_CLK_EN_REG, CAN_TX_IDX, CAN_RX_IDX, and ETS_CAN_INTR_SOURCE) are not declared in the current version of the ESP32 Arduino core library you're using.
Steps to Resolve the Issue:Update the ESP32 Arduino Core:
Ensure you are using the latest version of the ESP32 Arduino core. Open the Arduino IDE, go to Tools > Board > Boards Manager, search for "esp32", and update to the latest version.
Check the ESP32CAN Library:
The ESP32CAN library might not be compatible with the latest ESP32 Arduino core. Try using the M5Stack CAN library instead, as it is tailored for M5Stack products.
Alternative Library:
If the issue persists, consider using the ESP32 TWAI (CAN) API directly in your Arduino sketch. The TWAI API is the newer and recommended way to handle CAN communication on ESP32.
Verify Hardware Connections:
Ensure the Dial and Isolated CAN bus unit are correctly connected to the specified port (Port A) and that the pins are properly configured in your code.
Example Code for M5Stack CAN:
Here’s a basic example for initializing CAN on an M5Stack device:
#include <M5Stack.h>
#include "esp32_can.h"void setup() {
M5.begin();
CAN_init(0, GPIO_NUM_5, GPIO_NUM_4); // Example pins for CAN TX and RX
}void loop() {
// Your CAN communication logic here
}Additional Resources:
M5Stack CAN Unit Documentation
ESP32 TWAI API Reference