2022-03-17 06:53 AM
Hello everyone,
I've been trying to integrate a simple TouchGFX project into STM32CubeIDE (so that I can add my own code to it), it's supposed to print simple graphics on the screen of a STM32L4R9I-EVAL board, but I stumbled upon an issue in the LDTC initialization : I can't write the LTDC configuration in the correct registers. In HAL_LTDC_Init, the LTDC registers are supposed to be initialized with parameters (e.g. the display size goes in AWCR), but when monitoring them through the debugger's memory monitor at address 0x40016800, I only see zeros... Note that earlier it was all 0x2220, I have no idea why it changed. Also, I can see that other peripherals don't have this issue because there are non-zero bytes near address 0x40000000 (the start of memory-mapped peripherals).
I attach 3 screenshots at different points in the program's execution (using breakpoints), to show that the value of register AWCR does not change despite being written into. Plus 2 screenshots showing the memory monitor.
This is the code generated by CubeMX, I have not modified it. I also attach the full project. I created it from STM32CubeIDE as a C++ project. The CubeMX configuration is copied from the TouchGFX project, so they are identical.
Any help will be appreciated !
2022-03-17 07:12 AM
Ensure the LTDC clock is enabled before using it.
__HAL_RCC_LTDC_CLK_ENABLE();
2022-03-17 07:17 AM
Thank you for your quick answer ! I just checked that : this function is called in HAL_LTDC_MspInit before all the problems I saw, I verified it using breakpoints.
2022-03-17 09:02 AM
Your debug read reg attempt isnt real. xxxx->YYYY->ZZZZ debuger dont handle as access to reg.
Add SFR peripheral view to debuger and check LTDC real info
2022-03-18 01:48 AM
2022-03-19 08:46 AM
Maybe ltdc regs is bufered and writed all together after an event as screen refresh ...
2022-03-19 10:43 AM
Read out the RCC register where the LTDC clock is enabled, and check.
JW
2022-03-21 01:59 AM
The reference manual (and CubeMX's clock tree drawing) indicate that the LTDC is driven by the clock PLLSAI2. So I checked the associated RCC registers with the debugger and they seem correctly set :
PLLSAI2RDY = 1 : SAI2 PLL is locked
PLLSAI2ON = 1 : SAI2 PLL in ON
PLLRDY = 1 : Main PLL is locked
PLLON = 1 : Main PLL is ON
LTDCRST = 1 : LCD-TFT reset is on (not sure what it means)
LTDCEN = 1 : LTDC clock is enabled
And the frequency of the LTDC clock is set to 20 MHz through CubeMX.
As for the eventual buffering of the LTCD registers until some screen event, I originally became interested by those registers because there is no screen event (no interrupt from the LTDC). But the IER registers (which enables the LTDC interrupts) stays at zero, just like the others. In this situation I think I won't ever have any event from the screen. But of course I may be missing something.
2022-03-21 03:33 AM
> LTDCRST = 1 : LCD-TFT reset is on (not sure what it means)
You mean RCC_APB2RSTR.LTDCRST? It means exactly what you'd think: the LTDC module is held in reset. This is your problem.
JW
2022-03-21 03:43 AM
Alright, I found out it came from a line :
__HAL_RCC_LTDC_FORCE_RESET();
I remember adding it a few days ago, hoping it would trigger a reset of the LTDC, not hoping it would prevent it to load itself.
After removing it and re-running, I saw it does not change anything to the state of the LTDC registers (nor RCC). And if I stop the execution anytime later, I still see zero-valued registers.