Library 08- ILI9341 LCD for STM32F4

One the left is LCD on STM32F429 Discovery board and on the right is LCD shield from eBay.On STM32F429 Discovery board there is LCD with ILI9341 controller. It has 240 x 320 pixels resolution and 16bit or 18bit color depth, what gives you 65536 or 262144 different colors.

It has also a possibility of different way of connection, like serial, parallel, with VSYNC and HYSNC.

STM32F429 has also LTDC driver for LCD like that, but this driver we will use later. For now we will use SPI for driving in serial mode and some other pins for controlling.

I choose this way because on ebay there is a lot of this displays configuring for SPI driving.

If you want to use ILI9341 with LTDC on STM32F429-Discovery board, then check this library.

June 06, 2015

After some optimization videos from Jean-François Garcia and electrodacus I thought that adding that optimizations to my library is not bad idea.

So now, DMA is used for SPI and window/page settings is used before sending data to LCD for reducing time for LCD.

Currently, I’ve set these options:

  • SPI is changed from 8-bits to 16-bits before sending starts via DMA for correct colors,
  • page/window is supported for filling entire LCD, filling rectangle at desired position, drawing vertical or horizontal line
  •  Adding this feature also to fonts which first draws rectangle is not supported yet

So, for maximal support for this LCD, redownload all libraries because I’ve done some changes in TM SPI, TM DMA, TM SPI DMA and TM ILI9341 libraries.



  • Support for 7 x 10 and 11 x 18 pixel font sizes
  • Display string
  • Draw rectangles, circles, lines
  • LCD rotation in all 4 orientations
  • Support for \n and \n\r
    • \n put string into new line with x coordinate same as start x coordinate
    • \n\r put string into new line with x = 0 coordinate
  • Support for LCD display ON/OFF


    • STM32F4xx
    • STM32F4xx RCC
    • STM32F4xx GPIO
    • STM32F4xx SPI
    • STM32F4xx DMA
  • TM
    • TM SPI
    • TM DMA
    • TM SPI DMA
    • TM Fonts
    • TM GPIO
    • defines.h

On board, LCD is connected to:

SDO (MISO) PF8 Output from LCD for SPI Not used, can be left
LED 3.3V Backlight
SCK PF7 SPI clock
SDI (MOSI) PF9 SPI master output
D/C PD13 Data/Command register
RESET PD12 Reset LCD Not used on discovery board
CS PC2 Chip select for SPI
GND GND Ground
VCC 3.3V Positive power supply

Remember: This library can also be used, if you are not using STM32F429 Discovery. It can be used in previous STM32F4 Discovery board. All pins can be changed in defines.h file which is included in project.

By default, SPI5 is used, but you can change that also in defines.h file with

About library

When you included all files to you project, you have to initialize LCD first. Then you are able to work with.

Example describe everything what you need to start with,


Project is available on Github, download library below.


Owner of this site. Application engineer, currently employed by STMicroelectronics. Exploring latest technologies and owner of different libraries posted on Github.

You may also like...