2023-04-05 09:28 AM
I'm working with a custom STM32F105 board with two similar CAN circuits but CAN1 is not working.
I use STM32 HAL with this custom CAN lib which handles configuration and buffering.
It was working before with the same hardware but I can't get it woking anymore.
// create CAN instance
tSTM32_CAN &CANbus1 = *( new tSTM32_CAN(&hcan1, tSTM32_CAN::CAN250kbit) );
// enale CAN
CANbus1.InitCANFrameBuffers();
CANbus1.CANOpen();
CANbus1.SetCANFilter( true, 0, 0x00000000, 0x00000000 );
// Send message
void sendCANRequest() {
if (CANRequestScheduler.IsTime()) {
tSTM32_CAN::CAN_message_t message;
message.id = BMS_Messages[BMS_Message_i];
message.len = 0;
message.flags.extended = true;
CANbus1.CANSendFrame( &message );
}
}
If I replace &hcan1 with &hcan2 and connect to CAN2 it works fine.
CANSendFrame in the end calls HAL_CAN_AddTxMessage which returns HAL_OK.
The 3 TX mailboxes fill up but the message just never gets sent out.
I also checked the filter function which should not matter for sending but it works fine.
2023-04-05 11:03 AM
>>It was working before with the same hardware but I can't get it working anymore.
Go back to the last working code and diff it?
Double check clocks, pin assignments, AFIO clock, other remappings on the F1 that might conflict.
Check the Errata.
Not sure there's a lot of interest on the forum for old chips on custom boards.
2023-04-06 02:15 AM
Thanks for the hint checking all the Cube settings.
I moved the ADC regular conversion trigger form timer 3 to timer 4 channel 4 which somehow kills CAN1.