2022-04-03 10:44 PM
Hello Everyone,
I have a two arduino boards communicating with each other on a CAN Bus. Arduino is connected to CAN Bus via MCP2515 .
Both arduino are communicating correctly with each other. Here is an example of my transmitter on arduino:
/*************************************************/
#include <SPI.h>
#include <mcp2515.h>
/*******************MESSAGES DEFINITIONS*****************/
#include <SPI.h>
#include <mcp2515.h>
struct can_frame canMsg1;
struct can_frame canMsg2;
MCP2515 mcp2515(10);
void setup() {
canMsg1.can_id = 0x0F6;
canMsg1.can_dlc = 8;
canMsg1.data[0] = 0x8E;
canMsg1.data[1] = 0x87;
canMsg1.data[2] = 0x32;
canMsg1.data[3] = 0xFA;
canMsg1.data[4] = 0x26;
canMsg1.data[5] = 0x8E;
canMsg1.data[6] = 0xBE;
canMsg1.data[7] = 0x86;
canMsg2.can_id = 0x036;
canMsg2.can_dlc = 8;
canMsg2.data[0] = 0x0E;
canMsg2.data[1] = 0x00;
canMsg2.data[2] = 0x00;
canMsg2.data[3] = 0x08;
canMsg2.data[4] = 0x01;
canMsg2.data[5] = 0x00;
canMsg2.data[6] = 0x00;
canMsg2.data[7] = 0xA0;
while (!Serial);
Serial.begin(115200);
mcp2515.reset();
mcp2515.setBitrate(CAN_250KBPS, MCP_8MHZ);
mcp2515.setNormalMode();
Serial.println("Example: Write to CAN");
}
void loop() {
mcp2515.sendMessage(&canMsg1);
mcp2515.sendMessage(&canMsg2);
Serial.println("Messages sent");
delay(100);
}
/*************************/
Now I'm trying to receive data on an STM32F753Z8 with a ICTCAN33C71XXXXXXX00 transceiver module but nothing is being received in the STM32F753Z8 from the arduino side. Since the arduino's are communicating to each other.
I ahve also tried to receive the data on Arduino side fro the STM32. But I couldn't get success.
My code for STM32 is attached in a file. Any thoughts on what I'm doing wrong or what I'm missing?
I have set the NVIC interrupt on CAN2 RX1 intr.
Baudrate :250kbps
ABP1 peripheral Clock: 13.5 mHZ