6 years ago.

CAN bus operation Nucleo F746ZG

A quick question.

Using code based on the CAN demo with the Nucleo F746ZG I'm sending a CAN message once every half a second using a wait.

#include "mbed.h"

CAN can1(PD_0, PD_1);
char counter = 0;

int main() {
    printf("main()\n");
    CANMessage msg;
    while(1) {
        if(can1.write(CANMessage(1337, &counter, 1))) 
        {
            printf("wloop()\n");
            counter++;
            printf("Message sent: %d\n", counter);
        }
        wait(0.5);
    }
}

When I put a scope on the CAN lines I get the following, it looks like its transmitting much much faster than that, what is going on?

/media/uploads/joeh/newfile1.png

Thanks for your help.

1 Answer

6 years ago.

If no other nodes are connected to the CAN bus then what you see on the scope are most likely the automatically repeated transmits of your node because it does not get acknowledgement from others. To fix it, either connect at least one additional node to the CAN bus or try to run your node in loop-back mode.

Accepted Answer