cancel
Showing results for 
Search instead for 
Did you mean: 

hcan1 not working while hcan2 does work with same settings

MEige.1
Associate III

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.

2 REPLIES 2

>>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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MEige.1
Associate III

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.