cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L073 LCD Controller

RSoen.1
Associate II

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

4 REPLIES 4
RSoen.1
Associate II

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

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

JW

RSoen.1
Associate II

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.

> 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