Skip to main content
Visitor II
November 23, 2020
Question

STM32L073 LCD Controller

  • November 23, 2020
  • 5 replies
  • 1636 views

Just getting started with this uC and the ST toolset. I am trying to initialize the LCD controller but the init fails at:

if (HAL_LCD_Init(&hlcd) != HAL_OK)

 {

  Error_Handler();

 }

More specifically it times out at:

  /*!< Wait Until the LCD Booster is ready */

 while(__HAL_LCD_GET_FLAG(hlcd, LCD_FLAG_RDY) == RESET)

 {

  if((HAL_GetTick() - tickstart ) > LCD_TIMEOUT_VALUE)

  {  

   hlcd->ErrorCode = HAL_LCD_ERROR_RDY;

   return HAL_TIMEOUT;

  } 

 }

in the stm32l0xx_hal_lcd.c file.

Looks like the "LCD booster" is not getting turn on. I used the ioc configurator to setup the LCD.

Here is the generated init code:

  /* USER CODE END LCD_Init 1 */

 hlcd.Instance = LCD;

 hlcd.Init.Prescaler = LCD_PRESCALER_1;

 hlcd.Init.Divider = LCD_DIVIDER_16;

 hlcd.Init.Duty = LCD_DUTY_1_2;

 hlcd.Init.Bias = LCD_BIAS_1_4;

 hlcd.Init.VoltageSource = LCD_VOLTAGESOURCE_INTERNAL;

 hlcd.Init.Contrast = LCD_CONTRASTLEVEL_0;

 hlcd.Init.DeadTime = LCD_DEADTIME_0;

 hlcd.Init.PulseOnDuration = LCD_PULSEONDURATION_0;

 hlcd.Init.HighDrive = LCD_HIGHDRIVE_0;

 hlcd.Init.BlinkMode = LCD_BLINKMODE_OFF;

 hlcd.Init.BlinkFrequency = LCD_BLINKFREQUENCY_DIV8;

 hlcd.Init.MuxSegment = LCD_MUXSEGMENT_DISABLE;

 if (HAL_LCD_Init(&hlcd) != HAL_OK)

 {

  Error_Handler();

 }

Thanks

Rich

    This topic has been closed for replies.

    5 replies

    RSoen.1Author
    Visitor II
    November 23, 2020

    It works (Initializes) if I select the external VLCD...... We will probably use this source as it saves power but I would like to know why the internal source is not working...

    Explorer
    February 9, 2025

    Same here, switched to external source for VLCD and it works. Using NUCLEO-64.

    Super User
    November 23, 2020

    How is your LCD clock selected in RCC_CSR.RTCSEL ? Is the clock set there as source, enabled and running?

    JW

    RSoen.1Author
    Visitor II
    November 24, 2020

    I am not sure what RCC_CSR.RTCSEL is. I setup the clocks in the ioc configurator, I enabled the external LSE osc and it shows the RTC and LCD being clocked at 37.768 KHz. I am using a Nucleo board.

    Super User
    November 24, 2020

    > I am not sure what RCC_CSR.RTCSEL is.

    Read the description of RCC_CSR register in RCC chapter in Reference Manual.

    Read it out and check if set as appropriate.

    If LSE is the selected clock, check also if that is enabled. Do you have the crystal installed and jumpers set appropriately for LSE? Check if it's running by outputting it to a MCO pin if that's available and observing using oscilloscope, or enable RTC and observe if it's running.

    Alternatively you can try a different clock source. LSE can be tricky to run at times.

    JW

    Super User
    February 10, 2025

    And same question - How is your LCD clock selected in RCC_CSR.RTCSEL ? Is the clock set there as source, enabled and running?

    JW