STM32U5G7 - LTDC bricks when peripheral clock enabled?
All,
I have somehow concocted a CubeMX configuration (attached) that causes the CPU to latch up when the LTDC clock is enabled during HAL initialization. Here's what I'm seeing/doing:
- Debugger loads flash, breakpoints at HAL_Init() in main().
- Set a breakpoint on the first line of HAL_LTDC_MspInit() inside Core/Src/stm32u5xxx_hal_msp.c.
- Run program. main() calls MX_LTDC_Init(), which calls HAL_LTDC_Init(), which calls HAL_LTDC_MspInit(), stopping at the breakpoint.
- Open the Variables view, expand hltdc, then expand hltdc->Instance. Observe that the LTDC peripheral registers are viewable in the debugger.
- Step up to and then over the call to the macro __HAL_RCC_LTDC_CLK_ENABLE(). Observe that the LTDC peripheral register values go blank, and the debugger has lost communication with the MCU.
Here's the "before":
Before the crash
And here's the "after":
After the crash
My question is... why is this happening? It does this on both the U5G9 DK2 board and our custom board. I have a valid(?) 32.4 MHz clock going to the LTDC. It's sourced from PLL2R, which in turn is sourced from HSE (16 MHz). I created a quickie test project which just initializes the clocks and the UARTs, and I can get correct UART output from our board while running the CPU and peripheral buses on an HSE-derived PLLCLK (PLL1R), which should be proof that our 16 MHz crystal is good. I see the same behavior if I switch to using HSI (16 MHz) instead of HSE for PLL1 and PLL2.
A peripheral causing an internal fault when being accessed is, in my experience, an indicator of the peripheral not being clocked. But the peripheral registers are already readable until __HAL_RCC_LTDC_CLK_ENABLE() is called, at which point the CPU and debugger both die.
Now, here's the important bit... if you close the Variables view, such that the debugger is not accessing the LTDC peripheral memory, and you step over __HAL_RCC_LTDC_CLK_ENABLE(), the program continues to function. I am able to step over (F6) the rest of HAL_LTDC_MspInit() and return to HAL_LTDC_Init(). But once that function starts to access the LTDC registers to configure the peripheral, it dies. Again, here's the before:
Before program crash
And here's the after, trying to step over line 277:
After program crash
So it still dies even if you don't have the debugger Variables view open; it's the act of trying to read LTDC peripheral registers (after __HAL_RCC_LTDC_CLK_ENABLE() has been called) that kills the processor and debugger. I used the attached IOC file to generate a new STM32 CubeMX project, and the generated project exhibits this failure, so you should be able to use this IOC file to try to reproduce my failure. I'm running the latest IDE (v1.18.1, Windows) with the latest CubeMX packages.
Any idea what I'm doing wrong?
Dana M.
