cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746 DMA2D RGB to ARGB pixel format conversion not working

CMyco
Associate II

I am prototyping on the STM32F746G-DISCO board but I have a problem with the DMA2D.

I have used this micro on previous projects and even the DMA2D without issue, but this is the first time I have tried RGB888 to ARGB8888 pixel conversion.

If I use ARGB to ARGB, both in Memory to Memory (M2M) mode and M2M with conversion (PFC), it works fine. But if I set the foreground format to RGB888, the conversion produces bad data.

So for a 69x69 pixel RGB888 input image located in QSPI running in memory mapped mode, writing to an SDRAM buffer, I have the following (example) code:

while ( DMA2D->CR & DMA2D_CR_START )
{
  // wait for DMA2D complete
}
 
// setup the registers
DMA2D->CR = 1UL << 16; // M2M with PFC
// address of the input (QSPI)
DMA2D->FGMAR = 0x90000000; 
// Override the alpha (although unnecessary) and set the format to RGB888
DMA2D->FGPFCCR = 0xFF010001;
DMA2D->FGOR = 0; // no need to skip any pixels in the source
// output address - SDRAM buffer
DMA2D->OMAR = 0xC0000000;
DMA2D->OPFCCR = 0; // Output as ARGB8888
DMA2D->OOR = (LCD_WIDTH_IN_PIXELS) - 69; // image is 69x69 pixels
DMA2D->NLR = (69) | (69 << 16);
// start the process
DMA2D->CR = DMA2D_CR_START;

The output should be a square, but it ends up looking like 4 rectangles with missing lines.

Strangely, if I scale the values passed to the NLR and OOR by (4/3), the output looks correct.

Has anyone seen this? I am missing some configuration?

Thanks,

Chris

7 REPLIES 7

So, did you change the data source? RGB888 is 3 bytes per pixel, whereas ARGB8888 is 4 bytes per pixel.

JW

CMyco
Associate II

I set the source data to be all zeros and forced the alpha to be 0xFF (in the FGPFCCR register). That way is should work with RGB and ARGB. I am drawing a black square on a white background. Very simple. But when the source mode is set to RGB, it appears as though the pixels per line and output offset values are not being correctly interpreted in the DMA2D.

When in RGB888 mode, if I set the pixels per line to 92 (69 *4/3) and the OOR to 548 (411*4/3), I get the correct output (a black square).

My screen is 480x272, the image is 69*69. OOR should be (480-69) = 411.

If I use ARGB, pixels per line is 69 and the OOR is 411.

If this isn't clear i will post the code for both examples and photos of the output on the screen.

Thanks

Humm.

JW

CMyco
Associate II

Feel free to use the code I attached to test code reviewing skills. Don't know how I missed it but the fantastic support at ST spotted it for me (oops).

The last line of the code is wrong. Not sure how I did it, as it is correct throughout the rest of the code that uses the DMA2D.

@CMyco​ 

I don't get it. Are you talking about the snippet you posted in the first post? Can you please explain, what was exactly wrong?

JW

CMyco
Associate II

It should have been:

DMA2D->CR |= DMA2D_CR_START;

Ahhh... So you've changed mode to non-PFC... Nice! 🙂

Thanks for the explanation.

JW