ST7796S at a glance
Item | Value | Source |
|---|---|---|
Resolution | 320RGB × 480 | Sitronix datasheet V1.0 |
Frame memory | 320 × 480 × 18-bit = 2,764,800 bits | Sitronix datasheet |
Interfaces | 8080 MCU 8/9/16/18-bit, RGB 16/18-bit, 3-line SPI, 4-line SPI, MIPI | Sitronix datasheet |
Interface select | | Sitronix datasheet |
Pixel formats | RGB565, RGB666, RGB888 (RGB888 not listed for SPI) | Sitronix datasheet |
SPI clock | Write cycle ≥ 66 ns (about 15 MHz), read cycle ≥ 150 ns | Sitronix datasheet, 3-SPI and 4-SPI timing |
Supply | VDDI 1.65–3.3 V (VDDI ≤ VDD); VDD and VDDA 2.5–3.3 V | Sitronix datasheet |
Operating temperature | −30 to +85 °C | Sitronix datasheet |
The datasheet we used is Sitronix's V1.0 (2014/11), as hosted by Espressif. Its general description counts 960 source lines; that is the same thing as its 320 RGB source channels (320 × 3).
Why 3.5″ SPI modules use the ST7796S
A 320×480 panel can be driven by an ST7796S or an ILI9488. Over SPI the difference is the pixel format. The ST7796S datasheet lists RGB565 for both 3-line and 4-line SPI (COLMOD 3Ah = 05h), while the ILI9488 needs 18-bit pixels sent as 3 bytes.
Full 320×480 frame | Bytes | Time at 24 MHz | Time at 40 MHz |
|---|---|---|---|
ST7796S, RGB565 | 307,200 | 102 ms | 61 ms |
ILI9488, 18-bit over SPI | 460,800 | 154 ms | 92 ms |
These times are bits ÷ clock with no command overhead, so real frame rates are lower. They show why full-screen redraws of an ST7796S over SPI top out at roughly 10–16 fps and why UI libraries such as LVGL only redraw the areas that changed. If you need video-like motion, use the 8080 parallel bus instead: ESPHome's WT32-SC01 Plus configuration drives an ST7796 over an 8-bit (octal) bus.
SPI clock: datasheet versus boards
The datasheet's 66 ns minimum write cycle works out to about 15 MHz. Boards often run faster:
- The ESP32-3248S035 definitions in the rzeldent PlatformIO board package set the ST7796 SPI clock to 24 MHz.
- ESPHome's LilyGO T-Display-S3 Pro model sets
data_rateto 40 MHz.
Running above the datasheet figure depends on the panel, the FPC and your wiring, so treat it as something to test, not a given. If pixels tear or colors glitch, lower the clock first. Reads are slower still (150 ns cycle), so keep the clock down when reading the display ID or pixel data.
Initialization
TFT_eSPI, LovyanGFX and ESPHome all follow the same pattern:
- Send
0xF0(CSCON) with0xC3and0x96to unlock command set 2, which holds the power, gamma and timing registers. - Set inversion control (
0xB4), display function control (0xB6) and the panel's power and gamma values. - Send
0xF0with0x3Cand0x69to lock command set 2 again. - Set COLMOD to
0x55for RGB565, leave sleep mode and turn the display on.
The power, gamma and timing values differ between libraries. TFT_eSPI and LovyanGFX use the same gamma tables, while ESPHome's generic model sends a shorter sequence. They depend on the glass, so take them from your panel supplier's init code when you have it.
Colors, orientation and offsets
Most "wrong colors" reports are one of three settings:
- Red and blue swapped: the BGR bit in MADCTL (
0x36, bit0x08). TFT_eSPI defaults to BGR, and the ESP32-3248S035 definition sets the color space to BGR. - Negative image: display inversion. ESPHome turns
invert_colorson for the WT32-SC01 Plus and the T-Display-S3 Pro, but not in its generic ST7796 model. - Mirrored image: ESPHome's generic ST7796 model sets
mirror_x, and the ESP32-3248S035 definition setsDISPLAY_MIRROR_X.
Panels smaller than 320×480 use a window of the frame memory. ESPHome's T-Display-S3 Pro model uses a 222×480 area with a 49-pixel column offset. If the image is shifted or has a band of noise along one edge, check the offset before anything else.
ST7796S on the ESP32-3248S035
The ESP32-3248S035 is a 3.5″ board in the same family as the Cheap Yellow Display. The rzeldent PlatformIO board definitions give these pins:
Signal | GPIO |
|---|---|
MOSI | 13 |
MISO | 12 |
SCLK | 14 |
CS | 15 |
DC | 2 |
Backlight | 27 |
Reset | Not connected |
The two versions differ in touch:
- ESP32-3248S035C: capacitive GT911 on I2C (SDA 33, SCL 32, RST 25, INT 21, address
0x5D). - ESP32-3248S035R: resistive XPT2046 on the same SPI bus as the display (CS 33, IRQ 36, 2 MHz, pressure threshold 600). This is different from the 2.8″ CYD, where touch has its own pins.
Driver support
- TFT_eSPI:
ST7796_DRIVER, 320×480 by default. - LovyanGFX:
Panel_ST7796, which writes RGB565 by default and 3 bytes per pixel above 16-bit color depth. - ESP-IDF: Espressif's
esp_lcd_st7796component supports SPI, I80 and MIPI-DSI. - ESPHome: the
mipi_spicomponent'sST7796model, plus board models such as WT32-SC01-PLUS and T-DISPLAY-S3-PRO. - LVGL: has its own ST7796 driver.
Related pages
For the 320×480 alternative that needs 18-bit SPI, see ILI9488. For panel sizes and interface choices at this resolution, see our 3.5-inch TFT page and SPI display page.
ST7796S init code
// Outline of the sequence used by TFT_eSPI and LovyanGFX. Panel-specific power,
// gamma and timing registers (C1h, C2h, C5h, E0h, E1h, E8h) come from your panel datasheet.
write_cmd(0x01); delay_ms(120); // SWRESET
write_cmd(0x11); delay_ms(120); // SLPOUT
write_cmd(0xF0); write_data(0xC3); // CSCON: enable command 2 part I
write_cmd(0xF0); write_data(0x96); // CSCON: enable command 2 part II
write_cmd(0x36); write_data(0x48); // MADCTL: MX + BGR (TFT_eSPI default)
write_cmd(0x3A); write_data(0x55); // COLMOD: 16-bit RGB565
write_cmd(0xB4); write_data(0x01); // 1-dot inversion
// ... panel power, gamma and timing registers ...
write_cmd(0xF0); write_data(0x3C); // CSCON: disable command 2 part I
write_cmd(0xF0); write_data(0x69); // CSCON: disable command 2 part II
write_cmd(0x29); // DISPONDev boards using ST7796S
Display modules using ST7796S
ST7796S troubleshooting & FAQ
What is the difference between ST7796S and ILI9488?
Both drive 320×480 panels with on-chip frame memory, but over SPI the ST7796S accepts 16-bit RGB565 while the ILI9488 needs 18-bit pixels sent as 3 bytes. A full frame is 307,200 bytes on the ST7796S and 460,800 bytes on the ILI9488, so the ST7796S refreshes about a third faster on the same SPI clock. The init sequences differ, so use the driver for the chip that is actually fitted.
How fast can I clock ST7796S SPI?
The Sitronix datasheet specifies a minimum write clock cycle of 66 ns, about 15 MHz, and 150 ns for reads. Boards commonly run faster than that: the ESP32-3248S035 board definition uses 24 MHz and ESPHome’s LilyGO T-Display-S3 Pro configuration uses 40 MHz. If you see corrupted pixels, lower the clock first, and keep reads (such as reading the display ID) slow.
Why are the colors inverted or red and blue swapped on my ST7796 display?
These are two separate settings. Red and blue swapped means the RGB/BGR bit in MADCTL (0x36, bit 0x08) is wrong for the panel; TFT_eSPI defaults to BGR and the ESP32-3248S035 definition sets BGR. A negative-looking image means display inversion is wrong; ESPHome turns inversion on for the WT32-SC01 Plus and the T-Display-S3 Pro, but not in its generic ST7796 model. Change one setting at a time.
Sources
- Sitronix ST7796S datasheet V1.0 (hosted by Espressif)
- TFT_eSPI ST7796_Init.h and ST7796_Defines.h
- LovyanGFX Panel_ST7796.hpp
- ESPHome mipi_spi models (ST7796, WT32-SC01-PLUS)
- ESPHome mipi_spi LilyGO models (T-DISPLAY-S3-PRO)
- rzeldent platformio-espressif32-sunton: esp32-3248S035C/R board definitions
- Espressif esp_lcd_st7796 component
- LVGL ST7796 driver documentation
