Beruflich Dokumente
Kultur Dokumente
Application note
TFT LCD interfacing with the
high-density STM32F10xxx FSMC
Introduction
Interactive interfaces are more and more integrated into many applications such as medical
devices, process control, mobile phones and other hand-held devices. These interfaces are
based mainly on graphic HMIs (human machine interface) using color LCDs.
Worldwide, the desire for color support is growing dramatically. The purpose of this
application note is to address this aspect by describing how to use the STM32F10xxx FSMC
(flexible static memory controller) to drive a TFT color LCD. This document first describes
how to connect a color LCD to the FSMC, then it provides a TFT LCD interfacing example.
The demonstration firmware delivered with this application note, the STM32F10xxx
firmware library, and other such firmware are available for download from the
STMicroelectronics website: www.st.com.
Contents
4 Firmware description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.1 LCD driver firmware description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.2 Running the demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2.1 Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2.2 Demo startup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.2.3 Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.3 LCD demo applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.3.1 Internal Flash memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.3.2 NOR Flash memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.3.3 External SRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.3.4 NAND Flash memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.3.5 SD card . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2/45
AN2790 Contents
7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
8 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3/45
List of tables AN2790
List of tables
4/45
AN2790 List of figures
List of figures
5/45
STM32F10xxx flexible static memory controller (FSMC) overview AN2790
6/45
AN2790 STM32F10xxx flexible static memory controller (FSMC) overview
In the case where a synchronous memory is used, the user has to compute and set the
following parameters:
● CLKDIV: clock divide ratio
● DATLAT: data latency
Note that NOR Flash memory read operations can be synchronous if the memory supports
this mode, while write operations usually remain asynchronous.
When programming a synchronous NOR Flash memory, the memory automatically switches
between the synchronous and the asynchronous mode, so in this case, all parameters have
to be set correctly.
Figure 1 and Figure 2 show the different timings during a typical NOR Flash memory
access.
Memory transaction
A[25:0]
NADV
NEx
NOE
NWE
High
7/45
STM32F10xxx flexible static memory controller (FSMC) overview AN2790
Memory transaction
A[25:0]
NADV
NEx
NOE
1HCLK
NWE
8/45
AN2790 TFT LCD (thin-film-transistor liquid crystal display) interfacing with FSMC
The most common LCD MPU parallel interfaces are of the Intel 8080 (I80) and Motorola
6800 (M68) type.
The next section focusses on describing how to connect LCD Intel 8080-like and Motorola
6800-like interfaces with an STM32F10xxx FSMC.
LCD controller signals are divided into two types: data signals and control signals.
The data signals are connected to the LCD databus and depend on the LCD color depth (8
bits, 9 bits, 16 bits, 18 bits or 24 bits (true colors)).
The control signals are used to define the operation type (read or write), and whether the
operation consists in addressing (writing commands to) LCD registers or the display RAM.
9/45
TFT LCD (thin-film-transistor liquid crystal display) interfacing with FSMC AN2790
Table 2 describes the control signals for LCD Intel 8080-like and Motorola 6800-like
interfaces.
10/45
AN2790 TFT LCD (thin-film-transistor liquid crystal display) interfacing with FSMC
A typical connection between FSMC and LCD Intel 8080 is illustrated on Figure 3.
NEx CS
NOE RD
NWE RW
Ax RS
D0-D15 D0-D15
Figure 4 illustrates a typical connection between the FSMC and an LCD Intel 6800-like
interface.
11/45
TFT LCD (thin-film-transistor liquid crystal display) interfacing with FSMC AN2790
NEx CS
GPIO pin E
NWE R/W
Ax RS
D0-D15 D0-D15
Figure 5 shows an alternative connection of an LCD Motorola 6800-like interface with the
FSMC.
NEx CS
NOT E
NWE R/W
Ax RS
D0-D15 D0-D15
12/45
AN2790 TFT LCD (thin-film-transistor liquid crystal display) interfacing with FSMC
NE1 CS
NOE RD
NWE RW
Ax RS
D0-D15 D0-D15
Ax where x can be 16 to 23
ai15192
13/45
TFT LCD (thin-film-transistor liquid crystal display) interfacing with FSMC AN2790
14/45
AN2790 Interfacing the Ampire AM-240320L8TNQW00H TFT LCD with the FSMC
RS A0 PF00 Address A0
D0-D15 D0-D15 GPIOD/GPIOE Data D0-D15
CS NE4 PG12 Chip Enable
RD (E) NOE PD04 Ouput Enable
WR (R/W) NWE PD05 Write Enable
Figure 7 shows a typical connection between the STM32F10xxx microcontroller and the
Ampire LCD (ILI9320 controller). This connection is extracted from the shematic of the
STM3210E-EVAL evaluation board.
15/45
Interfacing the Ampire AM-240320L8TNQW00H TFT LCD with the FSMC AN2790
16/45
AN2790 Interfacing the Ampire AM-240320L8TNQW00H TFT LCD with the FSMC
17/45
Firmware description AN2790
4 Firmware description
High-level functions
These are the functions that can simply be called by the final application to execute all
needed configurations and perform high-end functionalities (LCD initialization, text writing,
display of bitmap images, configuration of all the hardware components, etc.). Table 9
presents these functions.
.
18/45
AN2790 Firmware description
4.2.1 Menu
Figure 8 shows the menu system of the STM32F10xxx LCD demonstration. The main menu
is shown on the left hand side. The UP, DOWN, RIGHT and LEFT joystick directions allow
the user to navigate between items in the main menu and the submenus. To enter a
submenu, press the SEL push-button (SEL push-button is the switch closure that occurs
when the joystick button is pushed). To exit a submenu select the Return menu and press
SEL.
Return
Return
Return
Return
Return
About
About
Return
ai15194
19/45
Firmware description AN2790
However, if the icons are correctly loaded into the NOR Flash memory, the Welcome screen
is displayed and the ST Logo appears on the LCD (see Figure 10).
Then, after 1 second, the STM32F10xxx slide shown in Figure 11 is displayed on the LCD
screen.
After the STM32F10xxx welcome screen, the main menu appears. It is displayed in the form
of a set of icons that shows all the submenus in the same screen. You can navigate using
the UP, DOWN, RIGHT and LEFT joystick directions to select the desired submenu. To enter
the desired submenu, press the SEL joystick push-button, and the new submenu
corresponding to the selected icon is displayed.
20/45
AN2790 Firmware description
!00 -AIN -ENU .AME
21/45
Firmware description AN2790
4.2.3 Navigation
The demonstration menu is based on circular navigation, submenu selection, item selection
and back capability as described in Figure 14.
Up
Up
Up
Up
Right Right Right Right
Left Item 1 Item 2 Item 3 Item 4
Left Left Left
Down
Down
Down
Down
Up
Up
Up
Up
Right Right Right Right
Left Item 5 Item 6 Item 7 Item 8
Left Left Left
Down
Down
Down
Down
Up
Up
Up
Up
Right Right Right
Left Item 9 Item 10 Item 11 Item 12 Right
Left Left Left
Select
Item 3.1 Item 3.1.1
t
lec
Se
Item 3.1.2
Item 3.2
Sel
Item 3
ect
...
...
Se Item 3.1.n
lec
t Item 3.n
Return
Return
ai15162b
The user navigates using the joystick push-buttons: RIGHT, LEFT, SEL, UP and DOWN
located on the evaluation board.
● the UP, DOWN, RIGHT and LEFT push-buttons are used to perform circular navigation
in the main menu and the current menu items
● the SEL push-button selects the current item
● the UP and DOWN push-buttons are used for vertical navigation in the submenus
● to return to the upper menu, go to the Return line and press SEL
22/45
AN2790 Firmware description
End WARNING
of slide show
You need to copy
Click images
bitmap to exit
in
Memory.
Press the JoyStick
to continue...
23/45
Firmware description AN2790
End
Copy of slide show
in progress.
Please to
Click wait...
exit
When the copy operation is complete, the message shown in Figure 17 appears on the LCD
screen.
End offinished.
Copy slide show
Press anyto
Click key exit
to
continue.
24/45
AN2790 Firmware description
If you press the SEL push-button while the animation is playing, the animation is stopped
and the submenu shown in Figure 20 is displayed.
End of 14920
Timing: slide e-6 sshow
FPS: 67to
Click fps
exit
Press any key to
continue.
25/45
Firmware description AN2790
End of 15994
Timing: slide e-6 sshow
FPS: 62to
Click fps
exit
Press any key to
continue.
End of 39249
Timing: slide e-6 sshow
FPS: 25to
Click fps
exit
Press any key to
continue.
26/45
AN2790 Firmware description
When the NOR Flash -> DMA-> LCD menu is selected, the animation shown in Figure 18
and Figure 19 is displayed on the LCD screen.
If you press the SEL push-button while the animation is playing, the animation is stopped
and the submenu shown in Figure 23 is displayed.
End of 37305
Timing: slide e-6 sshow
FPS: 26to
Click fps
exit
Press any key to
continue.
End
Copy of slide show
in progress.
Please to
Click wait...
exit
When the copy operation is complete, the message shown in Figure 25 appears on the LCD
screen.
27/45
Firmware description AN2790
End offinished.
Copy slide show
Press anyto
Click key exit
to
continue.
End of 28773
Timing: slide e-6 sshow
FPS: 34to
Click fps
exit
Press any key to
continue.
28/45
AN2790 Firmware description
End of 26649
Timing: slide e-6 sshow
FPS: 37to
Click fps
exit
Press any key to
continue.
End
Copy of slide show
in progress.
Please to
Click wait...
exit
When the copy operation is complete, the message shown in Figure 29 appears on the LCD
screen.
29/45
Firmware description AN2790
End offinished.
Copy slide show
Press anyto
Click key exit
to
continue.
End of 83615
Timing: slide e-6 sshow
FPS: 11to
Click fps
exit
Press any key to
continue.
30/45
AN2790 Firmware description
When the NAND Erase operation is complete, the message shown in Figure 32 is displayed
on the LCD.
NAND Erased
To exit Press SEL
To exit this submenu and return to the NAND physical format submenu, press SEL.
31/45
Firmware description AN2790
4.3.5 SD card
This part of the LCD demo is dedicated to displaying the bitmap pictures stored in the SD
card, as well as the computed one-frame display time. An internal 10 Kbyte buffer is used for
SD card buffer reading. Bitmap images are read and written to the LCD 10 Kbytes at a time.
It is first necessary to load the corresponding images into the dedicated SD card.
Note: When entering SD card display menus without first writing the images into the SD, blank
images are displayed on the LCD screen if the SD card has already been erased.
End
Copy of slide show
in progress.
Please to
Click wait...
exit
When the copy operation is complete, the message shown in Figure 34 is displayed on the
LCD screen.
End offinished.
Copy slide show
Press anyto
Click key exit
to
continue.
32/45
AN2790 Firmware description
End of 48192
Timing: slide e-6 sshow
FPS: 20to
Click fps
exit
Press any key to
continue.
33/45
Color TFT LCD interfacing with the FSMC: performance AN2790
Table 10 gives the speeds at which bitmap pictures are displayed from the different
memories.
Internal Flash 150 Kbytes 320 × 240 16 bits 14.920 ms 15.994 ms 67 fps / 62 fps
External SRAM 150 Kbytes 320 × 240 16 bits 28.773 ms 26.649 ms 34 fps / 37 fps
NOR Flash 150 Kbytes 320 × 240 16 bits 39.429 ms 37.305 ms 25 fps / 26 fps
NAND Flash 150 Kbytes 320 × 240 16 bits 83.615 ms - 11 fps
SD card (1-bit) 150 Kbytes 320 × 240 16 bits 81.257 ms - 12 fps
SD card (4-bit) 150 Kbytes 320 × 240 16 bits 48.192 ms - 20 fps
1. The CPU frequency is 72 MHz, FSMC frequency is 36 MHz. The SDIO clock frequency is 24 MHz.
2. The Systick timer was used to compute the timings, as well as Keil Compiler RVMDK V3.20 - O3,
Thumb2 Mode.
In the first case of a transfer from the internal Flash memory, CPU transfer is faster than
DMA transfer. This is due to the fact that the internal Flash memory is optimized for code
execution. However, it is usually better to use the DMA for the transfer as the CPU is then
free to do other jobs in parallel.
Note: If the CPU is executing code from the internal Flash memory, DMA transfer from the internal
Flash memory will be slowed down.
For the other cases (bitmap picture in external memory), the multilayer bus matrix ensures
seamless DMA transfer while the CPU is executing code from the internal Flash memory or
the RAM.
34/45
AN2790 LCD demo programming
This section explains how to use the DFU (device firmware upgrade) application to program
the LCD demonstration application. It also describes the files needed for the STM3210E-
EVAL board.
To save programming time using the DFU, proceede as follows:
● Use a certified USB Hub 2.0 high-speed between the STM3210E-EVAL board and your
PC
● Minimize the used PC RAM size by closing unused applications
● Use an efficient PC
Note: When using the DFU application, make sure that in the STM3210E-EVAL board, jumper
JP14 is in the position 2-3.
35/45
LCD demo programming AN2790
36/45
AN2790 LCD demo programming
5. This causes the window shown in Figure 37 to open. Select the STM32_FSMC-
LCD_Demo_NORFlash.dfu file.
6. Then click on the Open button. The previous window appears again, click on the
Upgrade button. A dialog window appears. Select Yes to continue (see Figure 38).
37/45
LCD demo programming AN2790
7. The M29W128 NOR Flash programming operation starts as shown in Figure 39.
38/45
AN2790 LCD demo programming
39/45
LCD demo programming AN2790
2. This causes the window shown in Figure 41 to open. Select the STM32_FSMC-
LCD_Demo.dfu file, as shown in Figure 41.
3. Then click on the Open button. The previous window appears again, click on the
Upgrade button. A dialog window appears. The dialog window shown in Figure 42 then
appears. Select Yes to continue.
40/45
AN2790 LCD demo programming
41/45
LCD demo programming AN2790
5. When the programming operation is complete, click on Leave DFU Mode. This causes
the target to switch from DFU mode to Application mode, as shown in Figure 44. And
the demonstration starts.
42/45
AN2790 Conclusion
7 Conclusion
Due to its performance and flexibility, the FSMC can easily interface color LCDs and serve
to build multimedia applications. The FSMC is suitable for displays that require low-power
and medium-resolution LCDs. Using the High-density STM32F10xxx FSMC, associated
with the MCU performance, signal processing and control function capabilities, to directly
interface LCD displays dramatically reduces the application system cost and complexity.
This application note has demonstrated how to create a display application by using the
STM32F10xxx FSMC to interface an LCD while using only a small amount of the
STM32F10xxx processing power.
43/45
Revision history AN2790
8 Revision history
44/45
AN2790
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT
RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING
APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY,
DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE
GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.
45/45