cancel
Showing results for 
Search instead for 
Did you mean: 

Why is MX_xxxx_Init()(HAL drivers) getting stuck in infinity loop if LL_RCC driver is used, instead of its HAL counterpart?

JoniS
Senior

Mcu: STM32F446RET6

STM32CubeMX 5.0.0 (STM32Cube V1.0)

So, yeah i figured out that if i use LL_RCC_DRIVER and then any periephal which only does have HAL_driver implemented by ST, it will get stuck in infinity loop in the corresponding init function.

ie.

 if (HAL_CAN_Init(&hcan1) != HAL_OK)  // <<- permanently stuck
  {
    Error_Handler();
  }

and the actual infinity loop is below.

 while ((hcan->Instance->MSR & CAN_MSR_SLAK) != RESET) // <-- Always true
  {
    if ((HAL_GetTick() - tickstart) > CAN_TIMEOUT_VALUE)  // <-- never true
    {
      /* Update error code */
      hcan->ErrorCode |= HAL_CAN_ERROR_TIMEOUT;
 
      /* Change CAN state */
      hcan->State = HAL_CAN_STATE_ERROR;
 
      return HAL_ERROR;
    }
  }

Now i ask, why i'm able to select LL and HAL driver mixture from cubeMX if it does not work anyway, using HAL_RCC driver and this proplem is gone, but that is not a fix.

Second, MX_CAN2_Init() always results into HAL_ERROR?

3 REPLIES 3
S.Ma
Principal

Some other fresh thread talk about Systick not working well with latest CubeMX.

Maybe there is a link here?

HAL_GetTick() relies on Systick.

If this one is not working, yes, the timeout may not happen as time is "frozen"?

I'm pretty sure it did return 0 always(need to check later again to be sure), which would make the timeout not work.​ But that is only if I try to use low level driver for the RCC, using HAL driver for RCC and it does work.(HAL_GetTick() does return values)

Well or atleast the init works, can't get the can loopback work properly, but that is issue for another topic.​

The SysTick_Handler needs to minimally call HAL_IncTick() for the counter to advance. The SystTick also needs to have sufficient preempt priority to cut through other callbacks or interrupts that have dependency.

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