cancel
Showing results for 
Search instead for 
Did you mean: 

LTDC won't initialize with the STM32H753

Gregory3
Associate III

Hello!

I'm using the Cube IDE with STM32H753 and trying to initialize the LTDC from HAL.

I already did this with success for the STM32F767.

But for the STM32H753 I have some problems with LTDC drivers.

The programm hangs up during debugging on the automatic genarated initialization routine.

The main looks like this:

int main(void)
{
  /* USER CODE BEGIN 1 */
 
  /* USER CODE END 1 */
 
  /* MCU Configuration--------------------------------------------------------*/
 
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
 
  /* USER CODE BEGIN Init */
 
  /* USER CODE END Init */
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* USER CODE BEGIN SysInit */
 
  /* USER CODE END SysInit */
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_LTDC_Init();

And the problem is the MX_LTDC_Init();

The program goes into it (inside the ltdc.c file):

void MX_LTDC_Init(void)
{
  LTDC_LayerCfgTypeDef pLayerCfg = {0};
 
  hltdc.Instance = LTDC;
  hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
  hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
  hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;
  hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
  hltdc.Init.HorizontalSync = 9;
  hltdc.Init.VerticalSync = 1;
  hltdc.Init.AccumulatedHBP = 29;
  hltdc.Init.AccumulatedVBP = 5;
  hltdc.Init.AccumulatedActiveW = 269;
  hltdc.Init.AccumulatedActiveH = 325;
  hltdc.Init.TotalWidth = 279;
  hltdc.Init.TotalHeigh = 329;
  hltdc.Init.Backcolor.Blue = 0;
  hltdc.Init.Backcolor.Green = 0;
  hltdc.Init.Backcolor.Red = 200;
  if (HAL_LTDC_Init(&hltdc) != HAL_OK)
  {
    Error_Handler();
  }
  pLayerCfg.WindowX0 = 0;
  pLayerCfg.WindowX1 = 240;
  pLayerCfg.WindowY0 = 0;
  pLayerCfg.WindowY1 = 320;
  pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
  pLayerCfg.Alpha = 255;
  pLayerCfg.Alpha0 = 0;
  pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
  pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
  pLayerCfg.FBStartAdress = 0;
  pLayerCfg.ImageWidth = 220;
  pLayerCfg.ImageHeight = 320;
  pLayerCfg.Backcolor.Blue = 0;
  pLayerCfg.Backcolor.Green = 0;
  pLayerCfg.Backcolor.Red = 250;
  if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)
  {
    Error_Handler();
  }
 
}

And then hangs on the HAL_LTDC_Init line.

Going further into that it looks like the problem is with the line 58:

HAL_StatusTypeDef HAL_LTDC_Init(LTDC_HandleTypeDef *hltdc)
{
  uint32_t tmp, tmp1;
 
  /* Check the LTDC peripheral state */
  if (hltdc == NULL)
  {
    return HAL_ERROR;
  }
 
  /* Check function parameters */
  assert_param(IS_LTDC_ALL_INSTANCE(hltdc->Instance));
  assert_param(IS_LTDC_HSYNC(hltdc->Init.HorizontalSync));
  assert_param(IS_LTDC_VSYNC(hltdc->Init.VerticalSync));
  assert_param(IS_LTDC_AHBP(hltdc->Init.AccumulatedHBP));
  assert_param(IS_LTDC_AVBP(hltdc->Init.AccumulatedVBP));
  assert_param(IS_LTDC_AAH(hltdc->Init.AccumulatedActiveH));
  assert_param(IS_LTDC_AAW(hltdc->Init.AccumulatedActiveW));
  assert_param(IS_LTDC_TOTALH(hltdc->Init.TotalHeigh));
  assert_param(IS_LTDC_TOTALW(hltdc->Init.TotalWidth));
  assert_param(IS_LTDC_HSPOL(hltdc->Init.HSPolarity));
  assert_param(IS_LTDC_VSPOL(hltdc->Init.VSPolarity));
  assert_param(IS_LTDC_DEPOL(hltdc->Init.DEPolarity));
  assert_param(IS_LTDC_PCPOL(hltdc->Init.PCPolarity));
 
#if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
  if (hltdc->State == HAL_LTDC_STATE_RESET)
  {
    /* Allocate lock resource and initialize it */
    hltdc->Lock = HAL_UNLOCKED;
 
    /* Reset the LTDC callback to the legacy weak callbacks */
    hltdc->LineEventCallback   = HAL_LTDC_LineEventCallback;    /* Legacy weak LineEventCallback    */
    hltdc->ReloadEventCallback = HAL_LTDC_ReloadEventCallback;  /* Legacy weak ReloadEventCallback  */
    hltdc->ErrorCallback       = HAL_LTDC_ErrorCallback;        /* Legacy weak ErrorCallback        */
 
    if (hltdc->MspInitCallback == NULL)
    {
      hltdc->MspInitCallback = HAL_LTDC_MspInit;
    }
    /* Init the low level hardware */
    hltdc->MspInitCallback(hltdc);
  }
#else
  if (hltdc->State == HAL_LTDC_STATE_RESET)
  {
    /* Allocate lock resource and initialize it */
    hltdc->Lock = HAL_UNLOCKED;
    /* Init the low level hardware */
    HAL_LTDC_MspInit(hltdc);
  }
#endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
 
  /* Change LTDC peripheral state */
  hltdc->State = HAL_LTDC_STATE_BUSY;
 
  /* Configure the HS, VS, DE and PC polarity */
  hltdc->Instance->GCR &= ~(LTDC_GCR_HSPOL | LTDC_GCR_VSPOL | LTDC_GCR_DEPOL | LTDC_GCR_PCPOL);
  hltdc->Instance->GCR |= (uint32_t)(hltdc->Init.HSPolarity | hltdc->Init.VSPolarity | \
                                     hltdc->Init.DEPolarity | hltdc->Init.PCPolarity);

The debugger says this:

0693W000000XIZZQA4.png

0693W000000XIbBQAW.png

So it looks like the Instance is initialized with zeros. But why?

Like I wrote , the code is automatic generated, so I don't delete anythig or write anything into the Init functions.

How can I deep deeper to see what could be the problem?

The application shall just display a simple one color picture first.

Thank you and regards,

Gregor

13 REPLIES 13
berendi
Principal

I ran into this issue too, and ended up rewriting SystemClock_Config() and LTDC initialization without HAL, setting the RCC and LTDC registers according to the reference manual.

CubeMX generated code locked the MCU up at the first time, provided unstable clocks at the second time.

Stathis
Associate II

I will be obligated if you could share your initialization code of RCC and LTDC.

Thanks in advance

Stathis

GTini.1
Associate II

Hi all, I have the same problem with STM32H743BI in my embedded board.

I replaced the old STM32F429 with this high performance MCU but the MX_LTDC_Init() crashes when it try to write the ltdc registers.

I found a note in the errata manual. There is a bug in some hardware revision (I have the “V�? rev).

The device stalls if you write the LTDC registers before the activation of the pixel clock, but the HAL drivers seems enable the pll3_r_ck before write the registers.

Anyway four or six eyes are better then 2...

Please let me know if someone find a solution, I am in a stall condition, thanks

Gianluca

GTini.1
Associate II

I solved this issue in my embedded board.

The problem, in my case, seems to be caused by a CubeMX bug.

The VCO Range of the PLL3 (the one used to generate the pixel clock of the LTDC module) cannot be selected in MEDIUM mode but only WIDE.

If one of the PLL outputs (P, Q, R) have a frequency higher than 192MHz there are no problems, otherwise the microcontroller will stall during the initialisation phase of the LTDC module because the pixel clock is not active.

It is possible to solve the problem in two ways, the first one is to set one of the three outputs, if not used (P, Q or R) with a clock at 200MHz for example, the other solution is to manually modify the PeriphClkInitStruct.PLL3 parameter. PLL3VCOSEL from RCC_PLL3VCOWIDE to RCC_PLL3VCOMEDIUM.

In this case, however, every time a change is made to the project on CubeMX, the parameter returns to the wrong value.

Gianluca