Interfacing STM32 Blue Pill Board with ILI9341 TFT Display

This STM32 project demonstrates how to interface the STM32 Blue Pill board with an ILI9341 TFT display module featuring a 320×240 pixel resolution.
The project illustrates how to:

  • Initialize and configure the ILI9341 display using the SPI protocol
  • Display text using various colors and sizes
  • Draw basic geometric shapes including: rectangles, circles, and lines with different colors.

This serves as a foundational example for building more advanced GUI projects with STM32 and color graphical displays.

About the STM32 Blue Pill Development Board:
The STM32 Blue Pill is a compact and low-cost development board based on the STM32F103C8T6 microcontroller from STMicroelectronics. This chip features an ARM Cortex-M3 core running at a maximum clock speed of 72 MHz. Its affordability, performance, and form factor have made it a favorite among hobbyists, students, and embedded systems developers.

Programming the STM32 Blue Pill:
To upload code to the Blue Pill board, one of the following tools can be used:

  • ST-Link Programmer: This is the recommended method. The ST-Link allows fast and reliable flashing and debugging via the SWD (Serial Wire Debug) interface.
  • USB-to-Serial Converter: Alternatively, you can use a USB-to-Serial converter to upload code through the UART bootloader. A popular example is the FT232RL USB-to-TTL module.

Note: If using the UART method, the BOOT0 pin must be set to 1 (HIGH) before powering on or resetting the board to enter bootloader mode.

Abbreviations:
TFT: Thin Film Transistor.
LCD: Liquid Crystal Display.
I2C: Inter-Integrated Circuit.
SPI: Serial Peripheral Interface.
IoT: Internet of things.

Hardware circuit STM32F103C8T6 Blue Pill with ILI9341 TFT display

About the ILI9341 TFT Display Module:
The ILI9341 is a widely used TFT LCD controller found in small to medium-sized displays, particularly suited for embedded systems, DIY electronics, and microcontroller-based projects. It is favored for its rich feature set, ease of use, and compatibility with many platforms such as Arduino, STM32, ESP32, and Raspberry Pi.

Key Features and Specifications:

  • Resolution: 240 × 320 pixels (portrait orientation by default)
  • Screen Size: Typically ranges from 2.2” to 3.2” diagonal
  • Color Depth: 16-bit (65K colors) to 18-bit (262K colors).
  • Interface: SPI (Serial Peripheral Interface) — 4-wire or 5-wire variants. Some modules also support parallel interfaces, though less common in hobby use
  • Backlight: Integrated LED backlight
  • Touchscreen Capability: Most ILI9341 displays come with a resistive touchscreen with an integrated touch screen controller (XPT2046)
  • SD Card Slot: Some ILI9341 modules feature a built-in SD card slot, eliminating the need for a separate SD card module

The image shows the ILI9341 TFT module with integrated component details:

ILI9341 TFT display module interfacing

The ILI9341 display module shown above includes an onboard 5 V to 3.3 V LDO regulator (U2), the part number of this regulator is: XC6206P332MR (662K).
A J1 solder jumper lets you select the module’s supply voltage:

  • Open J1 to power the module from 5 V (through the LDO).
  • Close J1 to bypass the LDO and run the module directly from 3.3 V.

This module also integrates the XPT2046 resistive touchscreen controller (–datasheet–), providing full touchscreen functionality. Finally, a small transistor (Q1) on the board is used to drive and control the LED backlight.

ILI9341 TFT Display Module Pinout:

The pinout of an ILI9341 TFT display module can vary slightly depending on the specific board version, but for the module shown above, the pin functions are categorized as follows:

Display Pins (Main TFT Interface):

  • VCC: Power supply input (typically 3.3 V or 5 V, depending on module design).
  • GND: Ground.
  • CS: Chip Select (active LOW).
  • RESET: Display reset pin (active LOW).
  • D/C (or DC): Data/Command control pin, with low for data mode and high for command mode.
  • SDI (MOSI): SPI data input (Master Out, Slave In).
  • SCK: SPI clock input.
  • LED: Backlight LED control pin (usually tied to VCC via resistor for constant backlight).
  • SDO (MISO): SPI data output (Master In, Slave Out).

Touch Screen Controller Pins (XPT2046 – SPI Interface):

  • T_CLK: Touch controller SPI clock input.
  • T_CS: Touch controller chip select (active LOW).
  • T_DIN: Touch controller SPI data input (MOSI).
  • T_DO: Touch controller SPI data output (MISO).
  • T_IRQ: Touch interrupt output (active LOW when screen is touched).

SD Card Slot Pins (SPI Interface):

  • SD_CS: SD card chip select (active LOW).
  • SD_MOSI: SPI data input to the SD card.
  • SD_MISO: SPI data output from the SD card.
  • SD_SCK: SPI clock input for the SD card.

Interfacing STM32 Blue Pill Board with ILI9341 TFT Display:
The image below shows the circuit schematic for interfacing the STM32 Blue Pill board with the ILI9341 TFT display module operating in SPI mode.

STM32 STM32F103C8T6 with ILI9341 color TFT display 240x320 pixel

Hardware Required:
This is a summary of the components needed to build this project:

  • STM32 Blue Pill board – STM32F103C8T6, 32-bit Arm Cortex-M3 MCU (– datasheet –)
  • ILI9341 TFT display module
  • Breadboard and jumper wires
  • STM32 microcontroller programmer (e.g., ST-Link, USB-to-Serial converter, etc.)

The ILI9341 TFT display board shown in the circuit diagram above has 14 pins: the first 9 pins are for the display, and the remaining 5 are for the touch module.
The display-side pins, numbered from 1 to 9 (from left to right), are as follows:
VCC (3.3V), GND (Ground), CS (Chip Select), RST (Reset), DC (or D/C: Data/Command), MOSI (or SDI), SCK (Clock), BL (Backlight LED), and MISO (or SDO). Where:

MOSI: Master-Out Slave-In
SDI: Serial Data In
MISO: Master-In Slave-Out
SDO: Serial Data Out

The ILI9341 display module is powered with 3.3V from the STM32 Blue Pill board. Jumper J1 (located on the back of the module) should be closed to ensure proper operation of the module at 3.3V.
The GND pin of the ILI9341 TFT display module is connected to the GND pin of the STM32 board, and the VCC pin of the display is connected to the 3.3V pin on the STM32 board.

The remaining signal pins of the ILI9341 display module are connected to the STM32 Blue Pill board as follows:

  • CS —> STM32 Blue Pill pin PA4.
  • RST  —> STM32 Blue Pill pin RST.
  • DC  —> STM32 Blue Pill pin PA3.
  • MOSI —> STM32 Blue Pill pin PA7.
  • SCK —> STM32 Blue Pill pin PA5.
  • BL —> STM32 Blue Pill pin 3V3.
  • MISO pin is not connected.

Note: Pins PA4, PA5 and PA7 are hardware SPI1 module pins of the STM32F103C8T6 microcontroller respectively for NSS (Slave Select), SCK (serial clock) and MOSI (master-out slave-in).

Interfacing STM32 Blue Pill Board with ILI9341 TFT Display – Arduino Code:
The Arduino IDE (Integrated Development Environment) is used to write the project code. Before compiling, support for the STM32 Blue Pill board must be added to the IDE.
You can install the STM32 Blue Pill board using the Boards Manager in the Arduino IDE. The official GitHub repository of the Arduino core for STM32 microcontrollers (STM32duino) is available at:
https://github.com/stm32duino/Arduino_Core_STM32

Note: This project was tested using version 2.10.1 of the STM32 Arduino core.

To program the STM32F103C8T6 microcontroller, you can use an FT232RL USB-to-Serial UART converter. Alternatively, the ST-LINK V2 programmer can also be used and is supported by the Arduino IDE.

To compile and run the Arduino code for this project, you’ll need to install two libraries from Adafruit Industries:

  1. Adafruit ILI9341 TFT Display Library: This is the driver library for the ILI9341 LCD. You can install it using the Arduino IDE Library Manager:

    • Navigate to Sketch → Include Library → Manage Libraries…

    • Search for “ILI9341” and install the library published by Adafruit.

  2. Adafruit GFX Library – This library provides graphics primitives (text, shapes, etc.). It is also available through the Library Manager:

    • In the same Library Manager, search for “Adafruit GFX” and install the version published by Adafruit.

Note: During the installation of the Adafruit ILI9341 driver library, the Arduino IDE may prompt you to install additional dependencies, such as Adafruit BusIO. Make sure to accept and install all required libraries.

Tested Library Versions
The following library versions were used to develop and successfully test this project:

  • Adafruit GFX Library: Version 1.12.1

  • Adafruit ILI9341 TFT Display Library: Version 1.6.2

  • Adafruit BusIO: Version 1.17.2

Programming Hints:
The required libraries are included in the Arduino code as shown below:

The hardware SPI1 module of the STM32F103C8T6 microcontroller is used to communicate with the ILI9341 TFT display. It is initialized in the Arduino code as follows:

The rest signal pins of the ILI9341 TFT is initialized as shown below:

The ILI9341 TFT display can be initialized using the following line, which ties together the SPI bus and the control pins previously defined:

Before using any display functions (e.g., print()drawLine(), etc.), the ILI9341 display must be properly initialized. If the initialization fails, the screen will remain blank.
Use the begin() function to initialize the display, as shown below:

Full Arduino Code for STM32:
Note: The Arduino code provided below is adapted from an example sketch included with the Adafruit ILI9341 library. Minor modifications have been made to suit the hardware setup used in this project, specifically, the STM32 Blue Pill board.

Interfacing STM32 Blue Pill Board with ILI9341 TFT Display Video:
The video below demonstrates the DIY hardware setup for interfacing an STM32 Blue Pill board with an ILI9341 color TFT display.

STM32 Blue Pill with ILI9341 Display – Proteus Simulation Video:
The video below demonstrates a Proteus simulation of the STM32 Blue Pill board interfaced with an ILI9341 TFT display.
Please note that the simulation circuit in Proteus differs from the actual hardware circuit. The real hardware schematic is shown above.

Proteus Simulation File Download:
You can download the Proteus simulation file from the link below.
Please note: Proteus version 8.15 or higher is required to open the project.
STM32 Blue Pill with ILI9341 – Proteus Simulation

Related Projects:
Arduino Interface with ST7789 Color TFT Display
Interfacing STM32 Blue Pill Board with ST7789 TFT Display
Interfacing STM32 Blue Pill with ST7735 Color TFT Display


Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top