trying to send and receive the data through can bus moduler using with nrf9160 and esp32 controller (using SPI)

Hi,

can anyone help me with this situations that i'm facing from a 1 month so i'm connecting esp32 controller to seengreat RS485 Dual CAN Bus moduler and the other hand i'm connecting nrf9160 to seengreat RS485 Dual CAN Bus moduler but i can't send or receive any messages through this and i attach the both screenshot from nrf serial terminal and from esp32 controller terminal and also i attach my overlay code and my both project files. i tried with 125,250,500 KBPS bus speed but i didn't make it and this can bus moduler have 16MHZ and it has 120 ohm resister attached with the moduler and i tried spi-max-frequency = <125000>,<250000>, <500000>, <1000000>.WACS (2).zipWACS_esp32 (2).zip

here is my overlay file code

// can mcp2515 drivers overlay

&pinctrl {
    spi3_default: spi3_default {
        group1 {
            psels = <NRF_PSEL(SPIM_SCK, 0, 13)>,
                    <NRF_PSEL(SPIM_MOSI, 0, 11)>,
                    <NRF_PSEL(SPIM_MISO, 0, 12)>;
        };
    };

    spi3_sleep: spi3_sleep {
    group1 {
        psels = <NRF_PSEL(SPIM_SCK, 0, 13)>,
                <NRF_PSEL(SPIM_MOSI, 0, 11)>,
                <NRF_PSEL(SPIM_MISO, 0, 12)>;
            low-power-enable;
        };
    };
};

/ {
    chosen {
        zephyr,canbus = &mcp2515;
    };
};

&spi3 {
    compatible = "nordic,nrf-spim";
    status = "okay";

    pinctrl-0 = <&spi3_default>;
    pinctrl-1 = <&spi3_sleep>;
    pinctrl-names = "default", "sleep";

    cs-gpios = <&gpio0 25 GPIO_ACTIVE_LOW>;

    mcp2515: can@0 {
        compatible = "microchip,mcp2515";
        reg = <0>;
        spi-max-frequency = <250000>;

        int-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;
        osc-freq = <16000000>;
        bus-speed = <250000>;
        status = "okay";
    };
};

// UART overlay
&uart2 {
    status = "okay";
    current-speed = <115200>;
};


i spend too much time on this and still didn't get anything from this so please help me to get through with this and what else i can do for debugging cuz i change the wires many times and now i order new can bus moduler to get confirmation about that is the moduler don't have the problem or what, i don't know

thanks 
vivek

Parents
  • Hi Vivek,

    Thanks for the detailed measurements, Vidar is not available so I am taking up your case.

    Your ESP32 shows TEC=128 (TXEP), which just means it's sending but never getting an acknowledgement back. Your nRF9160 shows REC=0 and no received frames, meaning it's not hearing anything on the bus at all. If the nRF were actually receiving your messages but not acknowledging them, I'd expect its REC counter to climb or at least a received frame to show up, but both stay flat. So I think this isn't a "normal mode / not acknowledging" issue, and it's not the Zephyr interrupt handling or the MCP2515 registers. The frames just aren't reaching the nRF's CAN chip. I believe that usually means the problem is on the hardware side, not the code.

    One thing worth knowing is the 60 Ω you measured only confirms the two termination resistors are connected, it doesn't confirm the nRF's CAN transceiver is actually powered. A transceiver with no power still reads 60 Ω.

    Could you check a couple of things for me:

    - Measure the VCC (power) pin of the CAN module on the nRF side, it should be 3.0-3.6 V.
    - With a scope or meter, watch CANH and CANL while the ESP32 is sending, you should see them move. If they stay flat, the signal isn't getting onto the bus.
    - If possible, run the ESP32's MCP2515 in loopback mode to confirm that board is fine on its own.

    Once we know the transceiver is properly powered and the bus lines are actually moving, the sample code should work. Send over what you find and we'll take the next step from there.

    Best regards,
    Syed Maysum

Reply
  • Hi Vivek,

    Thanks for the detailed measurements, Vidar is not available so I am taking up your case.

    Your ESP32 shows TEC=128 (TXEP), which just means it's sending but never getting an acknowledgement back. Your nRF9160 shows REC=0 and no received frames, meaning it's not hearing anything on the bus at all. If the nRF were actually receiving your messages but not acknowledging them, I'd expect its REC counter to climb or at least a received frame to show up, but both stay flat. So I think this isn't a "normal mode / not acknowledging" issue, and it's not the Zephyr interrupt handling or the MCP2515 registers. The frames just aren't reaching the nRF's CAN chip. I believe that usually means the problem is on the hardware side, not the code.

    One thing worth knowing is the 60 Ω you measured only confirms the two termination resistors are connected, it doesn't confirm the nRF's CAN transceiver is actually powered. A transceiver with no power still reads 60 Ω.

    Could you check a couple of things for me:

    - Measure the VCC (power) pin of the CAN module on the nRF side, it should be 3.0-3.6 V.
    - With a scope or meter, watch CANH and CANL while the ESP32 is sending, you should see them move. If they stay flat, the signal isn't getting onto the bus.
    - If possible, run the ESP32's MCP2515 in loopback mode to confirm that board is fine on its own.

    Once we know the transceiver is properly powered and the bus lines are actually moving, the sample code should work. Send over what you find and we'll take the next step from there.

    Best regards,
    Syed Maysum

Children
  • Hi syed,

    - one thing you have to know that i'm using seengreat rs485 dual CAN Bus module and i bought three of them, two from amazon and one from company's website cuz at first i thought there is something wrong with the CAN chip but now i still get the same result. i don't know what's wrong with this. please help me, i'm stuck in this situations from almost last three months.

    - I gave the VCC (power) from the esp32 to CAN module and it's 3.3v cuz i connect to 3.3v pin in esp32 so i didn't give the VCC (power) from nrf and i connect the nrf GND to esp32 GND. 

    - When i run esp32 code, CANH = 2.23v and CANL = 1.38v and it's stays where they are like it's not moving.

    - I run ESP32's MCP2515 in loopback mode and here is the output

    thanks

  • Hi Vivek,

    Thanks for the details, trying three modules with the same result tells us the modules themselves are fine, and your loopback test passing tells us the ESP32's CAN chip and wiring are fine too. So I think the problem isn't the parts or your code, it's on the physical bus side, where the signal actually goes out on the CANH/CANL wires.

    Normally on a working bus, CANH and CANL both sit near 2.5 V when idle and move together when a message is sent. Yours show CANH normal at 2.23 V but CANL stuck low at 1.38 V and not moving, that's the sign of a CAN transceiver that isn't being driven properly, which most likely comes down to power. As per my understanding each board has its own CAN transceiver, and both need a solid 3.3 V to work. Right now you're powering the modules from the ESP32's 3.3 V pin (Correct me if I am wrong) , which seems not able to hold a steady voltage for both so the nRF side transceiver is likely running under powered.

    For testing purpose, could you try powering both CAN modules from a separate, steady 3.3 V supply instead of the ESP32 pin, and keep all the grounds connected together. Then run your normal test again and watch whether CANH/CANL start moving. Let me know how it goes and we'll take it from there.

    Best regards,
    Syed Maysum

Related