CAN bus not working on Nucleo H743

Diego_Garcia
Mon, 07 Feb 2022 21:05:42 +0000
Bugs

Hello, I have been trying to use CAN bus with Mbed on a Nucleo H743 using Mbed OS 6.13 (I have tried with other versions too). And it is not working at all. That is: when sending a signal, the TX pin doesn’t output anything, and when receiving I can see the input signal with the oscilloscope going to the chip, but it is not reading anything.

I know setting up the CAN bus can be problematic, but I don’t think that is the problem. The transceiver seems to work fine, and the bus has the termination resistors. Also, I have been able to communicate Arduinos with this setup.

I have tried with Arduino, and a USB2CAN converter to test sending communication to the Nucleo board.

The as-simple-as-possible code I have been using for testing is the following:

//Receiving
#include "mbed.h"
#include <CAN.h>

//CAN can2(PB_5, PB_6, 500000); //RD, TD
CAN can1(PD_0, PD_1, 500000);

int main(){
    while (1){
        CANMessage msg;
        if (can1.read(msg))
            printf("Message received: %X\n", msg.data[0]);
        else
            printf("No Mesage: %X\n", msg.data[0]);
        ThisThread::sleep_for(500);
    }
}

//Sending
#include "mbed.h"
#include <CAN.h>

//CAN can2(PB_5, PB_6); //RD, TD
CAN can1(PD_0, PD_1, 500000);

int main(){
    while (1){
        can1.write(CANMessage(1337, "abcdefgh", 8));
        ThisThread::sleep_for(500);
    }
}

8 posts - 3 participants