Trouble with the can td pin on NUCLEO-F303K8

kanato_N
Wed, 16 Aug 2023 08:57:41 +0000
Mbed OS

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,

3 posts - 2 participants