Trouble with the can td pin on NUCLEO-F303K8

Hello. I had made trouble with CAN.
I want to send some data to NUCLEO-F303K8 from NUCLEO-446RE, but when I try to communicate between f446re to f303k8 using can, F303K8 couldn’t receive the data, and output of f446re says tderror 128.
But, when I try to communicate between f446re to f446re, it succeed and there was no tderror.
After I made this trouble, I checked the signals using the oscilloscope, and I found that there are no signals between RXD pin of MCP2562 and RD pin of F303K8, I could just see the horizontal line.
So, could you tell me the reason for this problem?
And, Are there any problems to use can transceiver with f303k8? Or are there any problems with can.read()?

Here is my environment
f446re: mbedos-5.15.7
f303k8; mbedos-2
transceiver: MCP2561/MCP2562 http://ww1.microchip.com/downloads/en/devicedoc/20005167c.pdf

Here is my f303k8 code
#include “mbed.h”

Serial pc(USBTX, USBRX, 115200);
CAN can(PA_11, PA_12);
DigitalOut led(PA_10);

void canData(void);

CANMessage msg;
unsigned char Can[8];

int main() {
can.reset();
can.frequency(500000);
while (1) {
canData();
pc.printf(“id:%d error:%d %d %d %d %d %d %d %d\n\r”, msg.id, can.rderror(), Can[0], Can[1], Can[2], Can[3], Can[4], Can[5], Can[6], Can[7]);
wait(0.2);
}
}
void canData(void) {
can.read(msg);
if (can.rderror() != 0) {
can.reset();
}
if (msg.id == 1227) {
memcpy(Can, msg.data, msg.len);
} else {
memset(Can, 0, sizeof(Can));
}
}

Here is my f446re code
#include “mbed.h”

#define CAN_ID 1337

RawSerial pc(USBTX,USBRX,115200);
DigitalOut led(PA_5);
CAN can1(PB_12,PB_6);
CANMessage msg;
char SayGoodbye = “ByeByeee”;

int main()
{
can1.frequency(500000);
led = 1;
pc.printf(“start\n\r”);
while(1){
can1.write(CANMessage(CAN_ID, &SayGoodbye[0], 8));
ThisThread::sleep_for(2);
if(can1.tderror()){
can1.reset();
ThisThread::sleep_for(2);
pc.printf(“can1 tderror:%d fail \n\r”, can1.tderror());
}
else{
pc.printf(“can1 tderror:%d succeed \n\r”, can1.tderror());
}

}

}

This is the circuit.

Best Regards,

Hello,

  • this comparison seems to be little bit strange because you run different Mbed versions on both sides. Try MbedOS 5.15.7 (bare metal) also for F303F8.
  • in generel is usually good to start with basic example CAN - API references and tutorials | Mbed OS 6 Documentation (bare metal required)
  • When you see no signal on RxD side then is nothing sended to CAN-BUS probably or connection (like correctly connected grounds) is not correct or transceiver is broken
  • The usage of reset is not correct, I think. The reset perform reset of CAN interface so its frequency settings is also set back to default (100000).
void canData(void) {
   can.read(msg);
   if (can.rderror() != 0) {
      can.reset();
      can.frequency(500000); // plus this line
}

BR, Jan

Hello Jan.
Thank you for your advice.
I could solve the problem!
I really appreciate your advice.
Best Regards,