<?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[CoreS3 + PWRCAN 13.2 Module working demo required]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">The current demo code from git will fail on compile.<br />
<a href="https://github.com/m5stack/M5Stack/blob/master/examples/Unit/CAN/CAN.ino" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5Stack/blob/master/examples/Unit/CAN/CAN.ino</a><br />
<em>C:\Users\Sen\AppData\Local\Arduino15\packages\m5stack\hardware\esp32\2.1.3/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/dport_reg.h:21,<br />
from d:\Arduino\libraries\ESP32CAN\src\CAN.c:38:<br />
d:\Arduino\libraries\ESP32CAN\src\CAN.c: In function 'CAN_init':<br />
d:\Arduino\libraries\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\Sen\AppData\Local\Arduino15\packages\m5stack\hardware\esp32\2.1.3/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)</em></p>
<p dir="auto">If use the sample code from here (by using driver/twai.h)<br />
<a href="https://github.com/m5stack/M5AtomS3/issues/26" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5AtomS3/issues/26</a><br />
The build is passed but fail to send the message<br />
<em>[  1000][I][esp32-hal-psram.c:96] psramInit(): PSRAM enabled<br />
[  1023][I][M5GFX.cpp:732] init_impl(): [M5GFX] [Autodetect] load from NVS : board:10<br />
[  1026][D][M5GFX.cpp:694] _read_panel_id(): [M5GFX] [Autodetect] read cmd:04 = 7f0000e3<br />
[  1027][I][M5GFX.cpp:1515] autodetect(): [M5GFX] [Autodetect] board_M5StackCoreS3<br />
[  1187][V][Touch_FT5x06.cpp:63] _check_init(): [FT5x06] CIPHER:0x64 / FIRMID:0x05 / VENDID:0x02<br />
[  1190][W][Power_Class.cpp:434] setExtOutput(): [Power] setExtPower(true) is canceled.<br />
[  1227][V][common.cpp:1403] writeBytes(): [LGFX] i2c write error : ack wait<br />
[  1228][V][common.cpp:1403] writeBytes(): [LGFX] i2c write error : ack wait<br />
[  1416][V][common.cpp:1403] writeBytes(): [LGFX] i2c write error : ack wait<br />
[  1417][V][common.cpp:1403] writeBytes(): [LGFX] i2c write error : ack wait<br />
[  1419][V][common.cpp:1403] writeBytes(): [LGFX] i2c write error : ack wait<br />
[  1426][V][common.cpp:1403] writeBytes(): [LGFX] i2c write error : ack wait<br />
[  1442][V][common.cpp:1403] writeBytes(): [LGFX] i2c write error : ack wait<br />
[  1452][V][common.cpp:1403] writeBytes(): [LGFX] i2c write error : ack wait<br />
[  1453][V][common.cpp:1403] writeBytes(): [LGFX] i2c write error : ack wait<br />
[  1464][V][common.cpp:1403] writeBytes(): [LGFX] i2c write error : ack wait<br />
[  1465][V][common.cpp:1403] writeBytes(): [LGFX] i2c write error : ack wait<br />
[  1468][V][common.cpp:1403] writeBytes(): [LGFX] i2c write error : ack wait<br />
Driver installed<br />
Driver started<br />
CAN Alerts reconfigured<br />
Message queued for transmission<br />
Alert: TWAI controller has become error passive.<br />
Alert: A (Bit, Stuff, CRC, Form, ACK) error has occurred on the bus.<br />
Bus error count: 2<br />
Alert: The Transmission failed.<br />
TX buffered: 0  TX error: 136   TX failed: 1<br />
Message queued for transmission<br />
Alert: A (Bit, Stuff, CRC, Form, ACK) error has occurred on the bus.<br />
Bus error count: 3<br />
Alert: The Transmission failed.<br />
TX buffered: 0  TX error: 144   TX failed: 2<br />
Message queued for transmission<br />
Alert: A (Bit, Stuff, CRC, Form, ACK) error has occurred on the bus.<br />
Bus error count: 4<br />
Alert: The Transmission failed.</em></p>
<p dir="auto">This is the sample code modified for the CoreS3, PWRCAN jumper G17 and G18 are switch on. Do you have any working demo for CoreS3 + PWRCAN? Thanks!</p>
<pre><code>#include "M5CoreS3.h"
#include "driver/twai.h"

// Pins used to connect to CAN bus transceiver:
#define RX_PIN 18
#define TX_PIN 17

// Interval:
#define TRANSMIT_RATE_MS 1000

#define POLLING_RATE_MS 1000

#define ARDUINO_USB_CDC_ON_BOOT 1

static bool driver_installed = false;

unsigned long previousMillis = 0;  // will store last time a message was send

void setup() {
    auto cfg = M5.config();
    CoreS3.begin(cfg);
    Serial.begin(115200);
    
    // Initialize configuration structures using macro initializers
    twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(
        (gpio_num_t)TX_PIN, (gpio_num_t)RX_PIN, TWAI_MODE_NORMAL);
    twai_timing_config_t t_config =
        TWAI_TIMING_CONFIG_500KBITS();  // Look in the api-reference for other
                                        // speed sets.
    twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();

    // Install TWAI driver
    if (twai_driver_install(&amp;g_config, &amp;t_config, &amp;f_config) == ESP_OK) {
        Serial.println("Driver installed");
    } else {
        Serial.println("Failed to install driver");
        return;
    }

    // Start TWAI driver
    if (twai_start() == ESP_OK) {
        Serial.println("Driver started");
    } else {
        Serial.println("Failed to start driver");
        return;
    }

    // Reconfigure alerts to detect TX alerts and Bus-Off errors
    uint32_t alerts_to_enable = TWAI_ALERT_TX_IDLE | TWAI_ALERT_TX_SUCCESS |
                                TWAI_ALERT_TX_FAILED | TWAI_ALERT_ERR_PASS |
                                TWAI_ALERT_BUS_ERROR;
    if (twai_reconfigure_alerts(alerts_to_enable, NULL) == ESP_OK) {
        Serial.println("CAN Alerts reconfigured");
    } else {
        Serial.println("Failed to reconfigure alerts");
        return;
    }

    // TWAI driver is now successfully installed and started
    driver_installed = true;
}

static void send_message() {
    // Send message

    // Configure message to transmit
    twai_message_t message;
    message.identifier       = 0x0F6;
    message.data_length_code = 4;
    for (int i = 0; i &lt; 4; i++) {
        message.data[i] = 0;
    }

    // Queue message for transmission
    if (twai_transmit(&amp;message, pdMS_TO_TICKS(1000)) == ESP_OK) {
        printf("Message queued for transmission\n");
    } else {
        printf("Failed to queue message for transmission\n");
    }
}

void loop() {
    if (!driver_installed) {
        delay(1000);
        return;
    }

    uint32_t alerts_triggered;
    twai_read_alerts(&amp;alerts_triggered, pdMS_TO_TICKS(POLLING_RATE_MS));
    twai_status_info_t twaistatus;
    twai_get_status_info(&amp;twaistatus);

    if (alerts_triggered &amp; TWAI_ALERT_ERR_PASS) {
        Serial.println("Alert: TWAI controller has become error passive.");
    }
    if (alerts_triggered &amp; TWAI_ALERT_BUS_ERROR) {
        Serial.println(
            "Alert: A (Bit, Stuff, CRC, Form, ACK) error has occurred on the "
            "bus.");
        Serial.printf("Bus error count: %lu\n", twaistatus.bus_error_count);
    }
    if (alerts_triggered &amp; TWAI_ALERT_TX_FAILED) {
        Serial.println("Alert: The Transmission failed.");
        Serial.printf("TX buffered: %lu\t", twaistatus.msgs_to_tx);
        Serial.printf("TX error: %lu\t", twaistatus.tx_error_counter);
        Serial.printf("TX failed: %lu\n", twaistatus.tx_failed_count);
    }
    if (alerts_triggered &amp; TWAI_ALERT_TX_SUCCESS) {
        Serial.println("Alert: The Transmission was successful.");
        Serial.printf("TX buffered: %lu\t", twaistatus.msgs_to_tx);
    }

    unsigned long currentMillis = millis();
    if (currentMillis - previousMillis &gt;= TRANSMIT_RATE_MS) {
        previousMillis = currentMillis;
        send_message();
    }
}

</code></pre>
]]></description><link>https://community.m5stack.com/topic/7411/cores3-pwrcan-13-2-module-working-demo-required</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 01:02:14 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/7411.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Mar 2025 17:17:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CoreS3 + PWRCAN 13.2 Module working demo required on Wed, 01 Oct 2025 13:35:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/omurice" aria-label="Profile: Omurice">@<bdi>Omurice</bdi></a> Bump Thread,</p>
<p dir="auto">There are three threads on the PWRCAN Module, and all of the say the demo does NOT work. I tried to use TWAI based code but it doesn't seem to work either.</p>
<p dir="auto">Is it possible to get a working demo on a CoreS3</p>
]]></description><link>https://community.m5stack.com/post/30023</link><guid isPermaLink="true">https://community.m5stack.com/post/30023</guid><dc:creator><![CDATA[ruairih2cs]]></dc:creator><pubDate>Wed, 01 Oct 2025 13:35:46 GMT</pubDate></item></channel></rss>