cancel
Showing results for 
Search instead for 
Did you mean: 

This specific CAN2 config crashes during HAL_CAN_Init(), why

Javier1
Principal

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.000bauds0693W000007ZNwVQAW.png 

0693W000007ZNxsQAG.png 

when i run the generated code it crashes riight here in HAL_CAN_Init();

0693W000007ZNz5QAG.png 

The init function timeouts right here and returns HAL_ERROR

0693W000007ZO0DQAW.png 

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

we dont need to firmware by ourselves, lets talk
1 ACCEPTED SOLUTION

Accepted Solutions
Javier1
Principal

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.

we dont need to firmware by ourselves, lets talk

View solution in original post

1 REPLY 1
Javier1
Principal

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.

we dont need to firmware by ourselves, lets talk