m32 Mcu
m32 Mcu
m32 Mcu
Application note
Introduction
This application note highlights how to refresh an LCD-TFT display via the FMC (flexible memory controller) interface using the
Chrom-ART Accelerator on STM32 microcontrollers listed in the table below.
This Chrom-ART Accelerator (DMA2D) is a specialized DMA dedicated to image manipulation.
The DMA2D can perform the following operations:
• Fill a part or the whole of a destination image with a specific color.
• Copy a part or the whole of a source image into a part or the whole of a destination image with a pixel format conversion.
• Blend a part and/or two complete source images with a different pixel format and copying the result into a part or the
whole of a destination image with a different color format.
On STM32 microcontrollers, the FMC is used to access the LCD-TFT display through a parallel interface.
This application note explains:
• how to connect the LCD-TFT display to the FMC interface
• how to configure the DMA2D for the LCD-TFT display refresh
• how to use the DMA2D byte reordering features to directly drive Intel 8080 displays
To fully benefit from this document, the user can refer to the product reference manual to get familiar with the STM32
Chrom‑ART Accelerator (DMA2D).
STM32L4x6 line
STM32L4R5/S5 line, STM32L4R7/S7 line, STM32L4R9/S9 line
Microcontrollers
STM32U5 series
STM32H7 series
1 General information
Reference documents
The following documents are available on www.st.com.
• Reference manual STM32L4x6 advanced Arm®-based 32-bit MCUs (RM0351)
• Reference manual STM32L4Rxxx/L4Sxxx advanced Arm®-based 32-bit MCUs (RM0432)
• Reference manual STM32U5 series Arm ®-based 32-bit MCUs (RM0456)
• Reference manual STM32H7Rx/Sx Arm ®-based 32-bit MCUs (RM0477)
• User manual Discovery kit with STM32L496AG MCU (UM2160)
• Embedded software for the STM32L4 Series and STM32L4 Series+ (STM32CubeL4)
A typical application displaying an image into an LCD-TFT display is divided in two steps.
• Step 1: creation of the frame buffer content:
– The frame buffer is built by composing graphical primitives like icons, pictures and fonts.
– This operation is done by the CPU running a graphical library software.
– It can be accelerated by a dedicated hardware used with the CPU through the graphical library
(Chrom-ART Accelerator (DMA2D)).
– The more often the frame buffer is updated, the more fluid are the animations.
• Step 2: display of the frame buffer onto the LCD-TFT display:
– The frame buffer is transferred to the display through a dedicated hardware interface.
– The transfer can be done using the CPU, the system DMA or using the Chrom-ART Accelerator
(DMA2D).
In a typical display application example using the STM32 microcontrollers, the F(S)MC is used as the hardware
interface to the LCD-TFT display, the graphical primitives like pictures, icons or fonts are stored in the external
Quad-SPI Flash memory and the frame buffer is stored in the internal SRAM. The transfer of the frame buffer to
the LCD-TFT display can also be managed by the Chrom-ART Accelerator (DMA2D), hence not using the CPU or
the DMA resources.
This is showed in the figure below.
STM32 microcontroller
Frame buffer in
DMA2D SRAM internal SRAM
Quad-SPI
F(S)MC
interface
Quad-SPI LCD-TFT
Flash display
Step 1
DT44235V2
The Chrom-ART Accelerator (DMA2D) can update the whole image on the display (full refresh) or only a part of it
(partial refresh).
The configuration of the Chrom-ART Accelerator (DMA2D) (full or partial refresh) is done by programming specific
registers through the high level HAL library function as shown in Section 4.
In the table below the signal names are provided according the Type B display bus interface (DBI) as described in
the MIPI® Alliance standard for display bus interface.
Display
VDD
AGND
Power block
VDDI
DGND
Host
CSX
RESX
TE
D/CX
Interface block WRX Interface block
RDX
D[15:0] or D[7:0]
DT44255V2
3.2 Display command set (DCS) software interface
The LCD-TFT displays can be controlled through the physical interface (here the F(S)MC bus) using software
commands according to the display command set (DCS), as defined in the MIPI Alliance specification for DCS.
The DCS commands are used to configure the display module and to transfer the frame buffer to the display.
data @ range
0xxxxx0000
The second option "an address bit of the F(S)MC address bus" makes the software simpler than the first option
with a dedicated GPIO, but it requires using the “high level” address to control the ‘data or command select
signal’.
The user cannot use for example the F(S)MC address LSB bit (F(S)MC_A0) to control the ‘data or command
select signal’. The user must use a “high enough” F(S)MC address bit in order to keep for this bit the same value
during the whole image frame buffer transfer.
LCD-TFT display
F(S)MC_D[15:0] Data[15:0]
(1)
F(S)MC_A[x] Data/command selection
The table below shows the minimum F(S)MC address bit that can be used depending on some image size.
Table 4. Minimum F(S)MC address bit to use depending on image size (16-bit RGB565 access)
Dma2dHandle.Instance = DMA2D;
/* DMA2D initialization */
hal_status = HAL_DMA2D_Init(&Dma2dHandle);
OnError_Handler(hal_status != HAL_OK);
hal_status = HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1);
OnError_Handler(hal_status != HAL_OK);
}
A full refresh is of course done in the same way but initializing the LCD first pixel at (0, 0) and the image size to
the LCD size.
LCD_ImagePreparation(0, 0, ST7789H2_LCD_PIXEL_WIDTH,
ST7789H2_LCD_PIXEL_HEIGHT);
hal_status = HAL_DMA2D_Start_IT(&Dma2dHandle,
(uint32_t)&RGB565_240x240, /* Source buffer in format RGB565 and size
240x240 */
(uint32_t)&(LCD_ADDR->REG), /* LCD data address */
1, ST7789H2_LCD_PIXEL_HEIGHT * ST7789H2_LCD_PIXEL_WIDTH); /* number of
pixel to transfer */
OnError_Handler(hal_status != HAL_OK);
On the STM32 microcontrollers, the pixel data are stored in the frame buffer memory in little-endian format. This
means that the least significant byte is stored at the lowest address and the most significant byte is stored at the
highest address.
For example: in case of the RGB888 pixel format, the blue component is stored at address 0 while the red
component is stored at address 2.
When the pixel data are transmitted to the LCD display via the F(S)MC, it starts with the least significant byte first,
which is the blue component in this example.
This creates a mismatch with some Intel 8080 LCD display color coding which requires the most significant byte
to be transmitted first (red component in case of the RGB888 pixel format).
This mismatch requires extra byte reordering steps to get the right byte order before transmitting the pixel data
through the F(S)MC.
The new DMA2D byte reordering features allow the user to reorder the data in the DMA2D output FIFO, enabling
to directly drive the LCD displays from a frame buffer with a classic RGB order without any extra software
manipulation.
Pixel 0 Pixel 1
Transfer
number 1 2 3
Red component
Green component
Blue component
Note: The 18 bpp displays have the same color coding except that in case of 18 bpp, R/G/B[6:0] are placed in
the most significant bits of the bus and the data lines D9, D8, D1 and D0 are ignored.
Pixel 0 Pixel 1
Transfer
number 1 2 3 4
Red component
Green component
Blue component
• 24 bpp (16.7M colors) and 18 bpp (262k colors) over 8-bit interface
The figure below shows the pixel color coding for 24 bpp over an 8-bit bus interface.
Pixel 0 Pixel 1
Transfer
number 1 2 3 4
Red component
Green component
Blue component
Note: The 18 bpp displays have the same color coding except that in case of 18 bpp, R/G/B[6:0] are placed in
the most significant bits of the bus and the data lines D9, D8, D1 and D0 are ignored.
Required operation
Color depth Interface bus width
Red blue swap Byte swap
8-bit No No
8 bpp (256 colors)
16-bit No Yes
8-bit No Yes
16 bpp (64k colors)
16-bit No No
8-bit Yes No
18 bpp (262k colors)
16-bit Yes Yes
8-bit Yes No
24 bpp (16.7M colors)
16-bit Yes Yes
Pixel 0 Pixel 1
Transfer
DT48350V2
Red component 1 2
number
Green component
Blue component
Note: On MCUs not supporting the byte swap, a hardware fix can be implemented by swapping the data lines of the
LCD interface on the board. The display D[15:8] lines are connected to the F(S)MC D[7:0] lines and the display
D[7:0] lines are connected to the F(S)MC D[15:8] lines.
DT48351V2
B0 [2] R0 [2] Green component
B0 [1] R0 [1] Blue component
@+0 B0 [0] @+0 R0 [0]
R1 [4] G1 [2]
R1 [3] G1 [1]
R1 [2] G1 [0]
R1 [1] B1 [4]
R1 [0] B1 [3]
G1 [5] B1 [2]
G1 [4] B1 [1]
@+3 G1 [3] @+3 B1 [0]
Pixel 1 G1 [2] R1 [4]
G1 [1] R1 [3]
G1 [0] R1 [2] 8-bit F(S)MC data bus
B1 [4] R1 [1] D7 R0 [4] G0 [2] R1 [4] G1 [2]
B1 [3] R1 [0]
D6 R0 [3] G0 [1] R1 [3] G1 [1]
B1 [2] G1 [5]
D5 R0 [2] G0 [0] R1 [2] G1 [0]
B1 [1] G1 [4]
D4 R0 [1] B0 [4] R1 [1] B1 [4]
@+2 B1 [0] @+2 G1 [3]
D3 R0 [0] B0 [3] R1 [0] B1 [3]
R0 [4] G0 [2]
D2 G0 [5] B0 [2] G1 [5] B1 [2]
R0 [3] G0 [1]
D1 G0 [4] B0 [1] G1 [4] B1 [1]
R0 [2] G0 [0]
D0 G0 [3] B0 [0] G1 [3] B1 [0]
R0 [1] B0 [4]
R0 [0] B0 [3] Pixel 0 Pixel 1
G0 [5] B0 [2] Transfer
G0 [4] number 1 2 3 4
B0 [1]
@+1 G0 [3] @+1 B0 [0]
G0 [2] R0 [4]
Pixel 0
G0 [1] R0 [3]
G0 [0] R0 [2]
B0 [4] R0 [1]
B0 [3] R0 [0] Red component
DT48352V2
B0 [2] G0 [5]
Green component
B0 [1] G0 [4]
@+0 B0 [0] @+0 G0 [3] Blue component
6 Conclusion
This application note explains how to easily transfer images to an LCD-TFT display via the F(S)MC interface
using the Chrom-ART Accelerator (DMA2D), without using the CPU or the DMA resources. A focus is given to the
correct control of the D/CX signal of the LCD-TFT display. Some code examples are provided to setup the
DMA2D.
This document presents the new byte reordering features of the DMA2D used to support an update of 16.7M and
262k color Intel 8080 displays directly through the F(S)MC.
Revision history
Table 6. Document revision history
Contents
1 General information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Chrom-ART Accelerator (DMA2D) application use-case overview . . . . . . . . . . . . . . . . . . . 3
3 LCD-TFT display on F(S)MC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.1 Hardware interface description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.2 Display command set (DCS) software interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.3 Controlling the D/CX signal with STM32 microcontrollers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4 Chrom-ART Accelerator (DMA2D) configuration in STM32CubeL4 . . . . . . . . . . . . . . . . . . 8
4.1 LCD partial refresh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5 New DMA2D features to support Intel 8080 displays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10
5.1 Intel 8080 interface color coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.2 DMA2D reordering features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.2.1 Red and blue swap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.2.2 Byte swap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.3 DMA2D reordering use case examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.3.1 24 bpp/18 bpp over 16-bit F(S)MC data bus interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.3.2 24 bpp/18 bpp over 8-bit F(S)MC data bus interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.3.3 16 bpp over 8-bit F(S)MC data bus interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
List of tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20
List of figures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
List of tables
Table 1. Applicable products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Table 2. F(S)MC signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Table 3. LCD-TFT signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Table 4. Minimum F(S)MC address bit to use depending on image size (16-bit RGB565 access) . . . . . . . . . . . . . . . . . . . 7
Table 5. Swap operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Table 6. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
List of figures
Figure 1. Display application typical use case. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Figure 2. Display bus interface specification. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 3. Memory map for LCD-TFT display access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Figure 4. Automatic control of LCD-TFT display data/command by F(S)MC interface . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Figure 5. 24 bpp over 16-bit interface color coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 6. 16 bpp over 8-bit interface color coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Figure 7. 24 bpp over 8-bit interface color coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Figure 8. DMA2D operations to support 24 bpp over 16-bit interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Figure 9. DMA2D operations to support 24 bpp over 8-bit interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Figure 10. DMA2D operations to support 16 bpp over 8-bit interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16