3

I have some data (in an array) to be displayed on a LCD. To do that I am using the DMA2D peripheral included in my STM32F4 microcontroller. The data I am trying to display are A4 formatted. Thus, every byte in my array (to be displayed) is used to draw two pixels.

The thing is, according to my Reference Manual, here is how the A4 data are fetched (page 261, table's last row) :

enter image description here

The thing is, even if my data are A4 formatted, they are "4-bit inverted". For example, instead of having 0xE8, I have 0x8E. The result : when it is displayed there is an inversion two by two of every vertical lines.

So my question is : is there any way to invert the way the DMA2D peripheral fetches data when A4 color mode is used ? I didn't find any register to do this but maybe there is a more "low level" way to achieve this.

Thanks !

EDIT : The Setup

The microcontroller used is a STM32F469. The peripherals used are :

  • The FMC to manage an external RAM. This RAM is used, among others goals, to store display buffers (one to draw, one to make calculus) ;
  • The LTDC with the DSI HOST in Video Mode. The output of the DSI HOST is then connected externally to a MIPI to LVDS chip converter ;
  • The DMA2D to achieve easily Memory-to-Memory transfers, Register-to-Memory transfers and Memory-to-Memory transfers with PFC and blending.

In this particular case, the A4 formatted data are used to draw fonts (that's why the blending part is used).

About the DMA2D configuration in this particular front drawing case :

DMA2D_HandleTypeDef charDMA2D;
uint32_t destination =  ((uint32_t)backBuffer + (4*(y*LCD_X_SIZE + x)));

charDMA2D.Instance = DMA2D;

charDMA2D.Init.Mode = DMA2D_M2M_BLEND;
charDMA2D.Init.ColorMode = DMA2D_OUTPUT_ARGB8888;
charDMA2D.Init.OutputOffset =  800 - 48;

charDMA2D.LayerCfg[0].AlphaMode = DMA2D_NO_MODIF_ALPHA;
charDMA2D.LayerCfg[0].InputColorMode = DMA2D_INPUT_ARGB8888;
charDMA2D.LayerCfg[0].InputAlpha = 0x00;
charDMA2D.LayerCfg[0].InputOffset = 0;

charDMA2D.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
charDMA2D.LayerCfg[1].InputColorMode = DMA2D_INPUT_A4;
charDMA2D.LayerCfg[1].InputAlpha = 0x00;
charDMA2D.LayerCfg[1].InputOffset = 0;

HAL_DMA2D_Init(&charDMA2D);
HAL_DMA2D_ConfigLayer(&charDMA2D, 0);
HAL_DMA2D_ConfigLayer(&charDMA2D, 1);
HAL_DMA2D_BlendingStart(&charDMA2D, (uint32_t)Character1Array, (uint32_t)BackgroundArray, destination, 48, 100);
HAL_DMA2D_PollForTransfer(&charDMA2D, 1000);

The function, for now, only allows to draw one specific character. As it is, it works almost perfectly. The character is drawn but not as expected as I specified earlier (line inverted two by two). I manually inverted every "4-bit" in a byte in the Character1Array and the character is drawn perfectly.

I am not drawing only fonts but also pictures (but not A4 formatted in input, more ARGB8888 formatted and it works well). The output format is always ARGB8888.

EDIT 2 : I made a script (external) to rewrite all my font data according to the right data fetching. I do not mark the post as solved since it doesn't answer my question and, honestly, I would prefer to make it work by not depending on an external script.

vionyst
  • 487
  • 2
  • 6
  • 14
  • There may be, but we need to know a lot more about your setup. What is your output format? Is the display connected through FSMC? Were it possible to use LTDC? Please include as many details as possible, they might be relevant. – followed Monica to Codidact Oct 16 '17 at 08:30

0 Answers0