2021-02-24 09:01 AM
Lets hope someone has a felicitously revelation, or a clue.
I am using a custom board with a nice stm32f105rbtx, fed with external XTAL.
Everything worked like a charm untill i configured the clock to be 72Mhz and readjusted the can parameters in CUBEMX to match 125.000bauds
when i run the generated code it crashes riight here in HAL_CAN_Init();
The init function timeouts right here and returns HAL_ERROR
/* Check Sleep mode leave acknowledge */
while ((hcan->Instance->MSR & CAN_MSR_SLAK) != 0U)
{
if ((HAL_GetTick() - tickstart) > CAN_TIMEOUT_VALUE)
{
/* Update error code */
hcan->ErrorCode |= HAL_CAN_ERROR_TIMEOUT;
/* Change CAN state */
hcan->State = HAL_CAN_STATE_ERROR;
return HAL_ERROR;
}
}
I have no idea why the canbus "stays in sleep mode" during initialization with this config.....
CubeMX file attached
Edit: now it happens with every canbus config, even old commits that were working previously.
Solved! Go to Solution.
2021-02-25 12:26 AM
Not sure howbut i fixed it:
I removed the nodes from the canbus line and flashed them with the canbus not connected,
the nodes are back to normal behaviour, maybe something hardwarewise was happening in the canbus.
2021-02-25 12:26 AM
Not sure howbut i fixed it:
I removed the nodes from the canbus line and flashed them with the canbus not connected,
the nodes are back to normal behaviour, maybe something hardwarewise was happening in the canbus.