cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to write into LTDC registers

Aksl
Associate III

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 !

15 REPLIES 15
TDK
Guru

Ensure the LTDC clock is enabled before using it.

__HAL_RCC_LTDC_CLK_ENABLE();

If you feel a post has answered your question, please click "Accept as Solution".
Aksl
Associate III

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.

MM..1
Chief III

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

0693W00000Kd2mPQAR.png

Aksl
Associate III

I didn't know this view, I checked but in the middle of LTDC initialization, all the LTDC registers are still at zero (see screenshot)...

MM..1
Chief III

Maybe ltdc regs is bufered and writed all together after an event as screen refresh ...

Read out the RCC register where the LTDC clock is enabled, and check.

JW

Aksl
Associate III

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.

> 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

Aksl
Associate III

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.