In this project, we explore the integration of STM32 microcontrollers with the ILI9341 TFT display using the Serial Peripheral Interface (SPI) protocol.
The ILI9341 is a widely used color TFT module with a resolution of 320×240 pixels (QVGA) and support for 65K colors. It is commonly used in IoT devices, home automation systems, wearables, and industrial control panels. The display is driven by the ILI9341 graphics controller, which supports both parallel and serial interfaces (SPI/I²C).
STM32CubeMX Configuration- Create a new project for STM32F103C8.
- Go to Clock Configuration → set system clock to 72 MHz.
- Configure SPI1 as Transmit-Only Master.
- Set Prescaler
= 64.
- Configure GPIO Pins:
-
PA4
→ Output (Chip Select - CS)
-
PB0
→ Output (Data/Command - DC)
-
PB1
→ Output (Reset)
- Generate initialization code.
- Create driver files:
- ili9341.h
, ili9341.c
- ili9341_touch.h
, ili9341_touch.c
(optional, if using touch input)
- Implement key driver functions:
-
ILI9341_Init(void)
-
ILI9341_Reset(void)
-
ILI9341_WriteCommand(uint8_t cmd)
-
ILI9341_WriteData(uint8_t data)
-
ILI9341_DrawPixel(uint16_t x, uint16_t y, uint16_t color)
-
ILI9341_FillScreen(uint16_t color)
-
ILI9341_DrawString(...)
- Add drawing primitives:
- DrawLine, DrawRectangle, DrawCircle, etc.
- In
main.c
, write application logic to:
- Initialize the display
- Render test patterns, text, or graphics
- Add components to schematic:
- STM32F103C8
- ILI9341 TFT Display (use generic SPI TFT if ILI9341 model is unavailable)
Required power connections and resistors
- Connect pins:
- SPI1
→ TFT (SCK, MOSI, CS)
- PB0
→ DC
- PB1
→ RESET
- Load the generated .hex firmware into the STM32.
- Run the simulation and verify TFT initialization and graphics rendering.
If you have any questions or suggestions don't hesitate to leave a comment below
Comments