Hello,
Does anyone had problem with receiving CAN message to STM32F1.
I have multiple devices on bus, some of them are ESP32(receiving and sending is working), STM32F1(only sending packet is working).
CDC is disabled. Core that I am using has added changes to support HardwareCAN library, just to say again, sending part is working with same init.
https://github.com/coddingtonbear/Ardui ... ardwareCAN
I am missing some important. IRQ or POLL mode maybe? Sending standard format ID.
Here is receiving code for stm:
Code: Select all
HardwareCAN canBus(CAN1_BASE);
void CANSetup(void)
{
CAN_STATUS Stat ;
canBus.map(CAN_GPIO_PA11_PA12);
Stat = canBus.begin(CAN_SPEED_500, CAN_MODE_NORMAL );
canBus.filter(0, 0, 0);
canBus.set_irq_mode();
Stat = canBus.status();
if (Stat != CAN_OK) {
;
}
}
void ProcessMessages(void)
{
CanMsg *r_msg;
if ((r_msg = canBus.recv()) != NULL){
Serial2.print(r_msg->ID);
Serial2.print("#");
Serial2.print(r_msg->Data[0]);
Serial2.print(".");
Serial2.print(r_msg->Data[1]);
Serial2.print(".");
Serial2.print(r_msg->Data[2]);
Serial2.print(".");
Serial2.print(r_msg->Data[3]);
Serial2.print(".");
Serial2.print(r_msg->Data[4]);
Serial2.print(".");
Serial2.print(r_msg->Data[5]);
Serial2.print(".");
Serial2.print(r_msg->Data[6]);
Serial2.print(".");
Serial2.println(r_msg->Data[7]);
canBus.free();
}
}
void setup() {
*((uint32_t*)0x40005c40) = 3 ;
*((uint32_t*)0x40005c44) = 0 ;
CANSetup() ;
Serial2.begin(115200);
Serial2.println("Serial2");
}
void loop() {
ProcessMessages() ;
delay(20) ;
}
BR,
Stefan