cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U0 LCD does not initialize with LSI clock

Lukasz Nowak
Associate III

I am working with STM32U073 and the LCD initialization code generated by CubeMx 6.12.0 (from STM32CubeIDE 1.16.0) does not work with LSI selected as the clock source.

HAL_LCD_Init() returns HAL_TIMEOUT due to LCD_WaitForSynchro() timing out.

The issue is caused by two problems:

1. With only LCD enabled (i.e. RTC disabled) the LSI oscillator is not enabled at all when SystemClock_Config() calls HAL_RCC_OscConfig():

 

void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Configure the main internal regulator output voltage
  */
  HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE2);

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
  RCC_OscInitStruct.MSIState = RCC_MSI_ON;
  RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_7;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

 

It should be:

 

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_MSI;
  RCC_OscInitStruct.LSIState = RCC_LSI_ON;
  RCC_OscInitStruct.MSIState = RCC_MSI_ON;

 

 

2. It appears that in the STM32U0 chip, there is no separate LCD clock mux and the RTC clock mux is used for the LCD.

Because of that, in order for the LCD to work, the RTC mux must be configured at the beginning of HAL_LCD_MspInit with this code:

 

    RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
    PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC;
    PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;

    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
    {
      Error_Handler();
    }

 

 

It would be great if CubeMx could fix these two problems for the U0 chip.

Thanks

1 REPLY 1
STTwo-32
ST Employee

Hello @Lukasz Nowak 

Thank you very much fir your recommandation. I will escalate tgis to the concerned team for a correction on the future.

Best Regards.

STTwo-32 

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.