cancel
Showing results for 
Search instead for 
Did you mean: 

STM32MP1 always fails on HAL_RCC_OscConfig

Bao Son Le
Associate II

Hi,

 

I just approach to STM32MP1 and want to port some project from STM32F4/L4 to M4 Core in STM32MP1.

 

To start, I'm just trying use engineering mode fisrt. I have a STM32MP157C-DK2 board and a new project is generated by STM32CubeMX, all configurations is default and I'm using STM32CubeMP1 v1.3.0.

 

Unfortunately, I always reach an issue when HAL_RCC_OscConfig always returns HAL_ERROR each time called from SystemClock_Config. Specifically, the following if condition in stm32mp1xx_hal_rcc.c is reached and my program stucks in an infinite loop.

if (IS_HSE_IN_USE())
{
  if ((__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) != RESET) && (RCC_OscInitStruct->HSEState != RCC_HSE_ON))
  {
    return HAL_ERROR;
  }
}

Am I missing something or I must write my own HAL_RCC_OscConfig? Again, all configurations is kept as default of STM32MP157C-DK2 board.

 

Thanks,

Bao Son.

6 REPLIES 6

Hello

Is crystal selected in RCC settings for HSE?

Try to give some more HSE Statup Timeout Value in RCC settings on STM32Cube

Bao Son Le
Associate II

Hello Vangelis,

Looks like that's not my problem. I checked again and found that if I start a new debugging session through the built-in debugger, it reassigns the PC's new address. That was not to my expectation as I wanted both the cores and the peripherals to be reset. In my case I was forced to hit the reset button before starting a new debugging session, which was a bit inconvenient 😅 .

In another development, I also found that my GPIO configuration was generated wrong, or more accurately it's not generated by neither STM32CubeMX nor CubeIDE. No one was created and I had to configure manually. I don't see this issue in F4 product line. Maybe, it's only appear on new models such as STM32MP1. Have you had same issue? It needs explanation from someone in ST. A tool that was created for convenience, but in practice it was frustrating :\ .

Thanks,

BS.​

Olivier GALLIEN
ST Employee

Hi @Bao Son Le​ ,

Sorry to see you post so late.

Are you using STM32CubeIDE or another IDE ?

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Olivier GALLIEN
ST Employee

Hi @Bao Son Le​ ,

I think I have explanation for both issues :

  • For hang in SystemClock_Config on debug session restart, please try to add HAL_RCC_Deinit () prior to HAL_Init()
  • For GPIO generation code not performed, take care to "reserved" the GPIO Pin to M4 ( right click on pin -> Reservation )

If one comment answer your question, please close this topic by choosing Select as Best. This will help other users to find that answer faster.

Thx

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi Olivier,

Sorry for late reply. About the first point, I'll tried and feedback later. However, with the second point, I see your suggestion just works when we configure input/output GPIOs. If I want to assign some GPIO pins as alternative function GPIOs (I2C, SPI etc.), they still don't generate as expected. Maybe the feature is still incomplete and we need to wait for the next updates, don't we?

Thank you,

Bao Son​

Hi @Bao Son Le​ ,

For second point regarding GPIO with alternate function assign to peripheral take care to assign the peripheral to the M4 context and check there's no conflict.

If still not working please be more specific ( exact GPIOs , Ip, function etc.. ) in order I can try to reproduce

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.