Hello,
Good morning!
I have interfaced Arduino CAN with PCAN using DB9 connector. I tried sending a CAN message from Arduino to PCAN. But the CAN message sent by Arduino can’t be seen in my Trace window of PCAN view*i.e RX message on PCAN
More information:
- i have checked the baudrate and its 500kbps on both ends
- 120 ohm not connected on PCAN side.
- TX led of Arduino CAN is red
Can you please guide in what is the mismatch or where should i correct for it to receive RX messages as well.
PCAN view: Trace window has no RX message
Serial monitor: can init is ok!
Here is the code for a CAN send:
#include <can-serial.h>
#include <mcp2515_can.h>
#include <mcp2515_can_dfs.h>
#include <mcp2518fd_can.h>
#include <mcp2518fd_can_dfs.h>
#include <mcp_can.h>
#include <SPI.h>
mcp2515_can CAN(10); //set SPI Chip Select to pin 10
unsigned char data[8];
void setup() {
Serial.begin(115200); //to communicate with Serial monitor
//tries to initialize, if failed → it will loop here for ever
START_INIT:
if(CAN_OK == CAN.begin(CAN_500KBPS)) //setting CAN baud rate to 500Kbps
{
Serial.println("CAN BUS Shield init ok!");
}
else
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
//loading the data bytes of the message. Up to 8 bytes
unsigned char data[8] = {‘C’, ‘a’, ‘r’, ‘t’, ‘e’, ‘r’, ‘a’, ‘!’};
}
void loop() {
//CAN.sendMsgBuf(msg ID, extended?, #of data bytes, data array);
CAN.sendMsgBuf(0x11, 0, 8, 0, data[8]);
delay(2000);
}
Please help me to know if i need to correct any way.
Also, let me know if any further information is needed
Thanks and regards
Sucheta