简体   繁体   English

STM32F429-DISC1 LCD 打印双像素

[英]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.我试图通过在 ARGB4444 配置中直接写入 SDRAM 来在STM32F429-DISC1的 LCD 上打印像素。

On the stm32f429i_discovery_lcd.c file I have changed the following line:stm32f429i_discovery_lcd.c文件中,我更改了以下行:

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 .最后我尝试red the 60500th pixel on Layer 1打印red the 60500th pixel on Layer 1 I multiply by 2 because addresses are 32 bits.我乘以 2,因为地址是 32 位。

*(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.似乎暗示像素是 16 位。 Since this is on a microcontroller, I would assume the framebuffer to be packed, ie 16 bits per pixel.由于这是在微控制器上,我假设要打包的帧缓冲区,即每像素 16 位。

But this:但是这个:

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

writes 32 bits, ie it clobbers the neighboring pixel too.写入 32 位,即它也会破坏相邻像素。 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 .进行计算的确切类型取决于SDRAM_BANK_ADDR的类型,即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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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