简体   繁体   中英

STM32F429-DISC1 LCD prints double pixels

I am trying to print pixels on the LCD of STM32F429-DISC1 by directly writing to the SDRAM in an ARGB4444 configuration.

On the stm32f429i_discovery_lcd.c file I have changed the following line:

LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565

for

LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_ARGB4444;

In my main I call the following initializers:

LCD_Init();
LCD_LayerInit();
LTDC_Cmd(ENABLE);

and finally I try to print red the 60500th pixel on Layer 1 . I multiply by 2 because addresses are 32 bits.

*(uint32_t *) (SDRAM_BANK_ADDR + 60500 * 2) = 0xFF00;

As a side note:

uint32_t SDRAM_BANK_ADDR = 0xD0000000 //Beginning of Layer 1

The red pixel gets printed, but besides there's a black pixel. Here is a picture: 正确的红色像素 + 错误的像素

What's wrong?

Thanks

This:

LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_ARGB4444;

seems to imply that pixels are 16-bit. Since this is on a microcontroller, I would assume the framebuffer to be packed, ie 16 bits per pixel.

But this:

*(uint32_t *) (SDRAM_BANK_ADDR + 60500 * 2) = 0xFF00;

writes 32 bits, ie it clobbers the neighboring pixel too. Note that the above does not cast the actual address when calculating it, that is done by inside the right set of parenthesis. The exact type at which the calculation is made depends on the type of SDRAM_BANK_ADDR , which is uint32_t . That integer value then needs to be cast into a pointer to the pixel, before the write, and that is done by the cast to the left.

A fix would simply be:

*(uint16_t *) (SDRAM_BANK_ADDR + 60500 * 2) = 0xFF00;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM