How to use a 1.77 inch TFT with a Tiva C board?
How to use a 1.77 inch TFT with a Tiva C board
To drive a 1.77 inch TFT display with a Tiva C board, you need to connect the display’s SPI interface and RGB control lines to the TM4C123G or TM4C1294 microcontroller, then initialize the ILI9163C or ST7735 driver chip inside the module. This specific display, often called a 1.77 inch spi mcu rgb tft display, uses a 128x160 pixel resolution and a 16-bit RGB565 color format. The Tiva C board, based on ARM Cortex-M4F, runs at 80 MHz with 256 KB flash and 32 KB SRAM on the TM4C123G model, which is enough to handle the SPI clock up to 20 MHz and the frame buffer. You must wire the display’s CS, DC, RESET, SDA, and SCK pins to the Tiva’s SSI0 or SSI1 peripheral, and provide 3.3V power from the board’s regulator. The display’s backlight LED typically draws 20 mA at 3.3V, so you can drive it directly from a GPIO pin through a 100-ohm resistor. The Tiva C board’s GPIO pins can source up to 8 mA each, so for the backlight, use a transistor or a dedicated PWM pin to avoid overloading. The display’s logic voltage is 3.3V, matching the Tiva C’s I/O levels, so no level shifting is needed. The interface uses 4-wire SPI with a separate data/command pin, plus the RGB565 format requires 16-bit data per pixel, which you send as two 8-bit bytes over SPI. The total frame buffer size for 128x160 pixels at 16-bit color is 40,960 bytes, which fits in the Tiva C’s SRAM if you use a single buffer, but double-buffering requires 81,920 bytes, exceeding the 32 KB limit on TM4C123G. So you must use a single buffer and update the display line by line, or use the Tiva’s DMA to transfer data from flash to SPI without blocking the CPU. The display’s driver chip, typically the ILI9163C, supports a maximum SPI clock of 20 MHz, but the Tiva C’s SSI module can generate up to 20 MHz when the system clock is 80 MHz and the prescaler is set to 4. At 20 MHz, sending a full 128x160 frame takes about 40,960 bytes × 8 bits per byte / 20,000,000 bits per second = 16.384 milliseconds, which is 61 frames per second theoretically. But the command overhead and the display’s internal timing reduce this to about 30-40 FPS in practice. The Tiva C’s interrupt latency is about 12 cycles at 80 MHz, so using DMA reduces CPU load to near zero during SPI transfers. You can use the Tiva’s uDMA controller to move data from a buffer in SRAM to the SSI0 data register, triggering a transfer complete interrupt after each frame. The display’s initialization sequence includes setting the sleep mode, adjusting the gamma curve, and configuring the RGB interface. The ILI9163C datasheet specifies 40 commands for full initialization, including 0x11 (sleep out), 0x36 (memory access control), 0x3A (interface pixel format), and 0x2A/0x2B (column and page address set). The Tiva C’s GPIO pins for the display must be configured as outputs with push-pull mode, and the SSI pins as alternate function. The typical pin mapping for TM4C123G LaunchPad is: PA2 (SSI0Clk) to SCK, PA3 (SSI0Fss) to CS, PA4 (SSI0Rx) not used, PA5 (SSI0Tx) to SDA, PB0 to DC, PB1 to RESET, and PB2 to backlight PWM. The display’s backlight can be controlled with a 1 kHz PWM from a timer, using a 50% duty cycle for typical brightness. The current consumption of the display with backlight on is about 40 mA at 3.3V, so the Tiva C’s 3.3V regulator can handle it, but if you use a battery, add a 100 µF capacitor near the display’s power pins to filter noise. The SPI wiring must be kept short, under 10 cm, to avoid signal degradation at 20 MHz. Use twisted pairs for SCK and SDA, and a ground wire between the boards. The display’s CS pin must be pulled high with a 10k resistor to prevent floating during Tiva C reset. The RESET pin is active low, so you can connect it to the Tiva’s reset line or a GPIO that toggles low for 1 ms at startup. The DC pin controls data/command: low for command, high for data. The display’s driver chip requires a 5 ms delay after power-on before sending commands, which you can implement with a simple loop using the Tiva’s SysTick timer. The SysTick runs at 80 MHz, so a 5 ms delay is 400,000 cycles. Use a volatile variable and a while loop for accurate timing. The initialization sequence starts with sending command 0x01 (software reset), then wait 120 ms, then 0x11 (sleep out) with 150 ms delay, then 0x36 (memory access control) set to 0x08 for RGB color order, then 0x3A (interface pixel format) set to 0x05 for 16-bit color, then 0x2A (column address set) with start 0 and end 127, then 0x2B (page address set) with start 0 and end 159, then 0x29 (display on) with 50 ms delay. After that, you can send pixel data using the 0x2C (memory write) command. The pixel data must be sent as two bytes per pixel: high byte (bits 15-8) then low byte (bits 7-0), where the RGB565 format uses 5 bits for red, 6 bits for green, and 5 bits for blue. For example, a red pixel is 0xF800, which is high byte 0xF8 and low byte 0x00. The Tiva C’s SSI sends data MSB first, so you need to pack the 16-bit color into two bytes and send them sequentially. You can use a union or bit shifting to convert. The display’s driver chip automatically increments the column and page address after each pixel, so you can send all 20,480 pixels in a single burst by setting the column and page range once. But if you want to update only part of the screen, you must set the window address first. The Tiva C’s SRAM can hold a 40,960-byte buffer, but you can also use the flash to store pre-rendered images, since the TM4C123G has 256 KB flash. A 128x160 image at 16-bit color takes 40,960 bytes, so you can store about 6 images in flash. To display an image from flash, use the Tiva’s flash read functions to copy the data to SRAM, then send it via SPI. The flash read speed is about 20 MHz, so the bottleneck is the SPI transfer. The display’s response time is about 10 ms for typical transitions, so the persistence of vision works at 30 FPS. The viewing angle of this TFT is 60 degrees in all directions, with a contrast ratio of 500:1 typical. The brightness is 250 cd/m² with the backlight at full current. The operating temperature range is -20°C to +70°C, so it works in most environments. The Tiva C board’s temperature range is -40°C to +85°C, so the display is the limiting factor. The display’s interface uses a 0.5 mm pitch FPC connector, which you can solder to a breakout board or use a ZIF socket. The Tiva C LaunchPad has 2x20 pin headers, so you can use female-to-male jumper wires for prototyping. But for a permanent setup, use a custom PCB with a 0.5 mm FPC connector and 100 nF decoupling capacitors near each power pin. The display’s driver chip has a built-in voltage generator for the LCD bias, so no external components are needed. The chip also includes a frame memory of 128x160x18 bits, but the Tiva C doesn’t use it because it sends data continuously. The SPI protocol for the display is simple: pull CS low, send a command byte with DC low, then send data bytes with DC high. The display ignores the data if the command doesn’t expect it. For example, the 0x2A command expects 4 data bytes: column start high, column start low, column end high, column end low. So you must send exactly 4 bytes after the command. The Tiva C’s SSI can be configured in Motorola SPI mode with 8-bit data, clock polarity 0, and phase 0. The clock idle is low, and data is sampled on the rising edge. The display’s datasheet specifies the SPI mode as mode 0, so this matches. The maximum SPI clock is 20 MHz, but the Tiva C’s SSI can go up to 20 MHz only if the system clock is 80 MHz and the prescaler is 4. If you use a lower system clock, the SPI speed drops. For example, at 40 MHz system clock, the maximum SPI clock is 10 MHz. The frame rate at 10 MHz is about 15 FPS, which is still acceptable for static images. The display’s refresh rate is 60 Hz internally, but the SPI update rate determines the actual frame rate. The Tiva C’s uDMA can be configured to transfer from a buffer to the SSI0 data register with a burst size of 4 bytes. The DMA channel for SSI0 transmit is channel 8 on TM4C123G. You need to set the DMA control table in SRAM, configure the source address as the buffer, destination address as the SSI0 data register (0x40008008), and set the transfer size to 40,960 bytes. The DMA transfer completes in about 2 ms at 20 MHz, leaving the CPU free to do other tasks. The interrupt handler for DMA completion can then set a flag to update the buffer. The Tiva C’s interrupt priority must be set low to avoid blocking other interrupts. The display’s backlight can be controlled with a PWM timer, such as Timer0 in PWM mode. The PWM frequency should be above 200 Hz to avoid flicker, and 1 kHz is typical. The duty cycle can be set from 0% to 100% using the Tiva’s PWM generator. The GPIO pin for backlight must be configured as a timer output. The Tiva C’s PWM module has a 16-bit counter, so you can set the load value to 80,000 for 1 kHz at 80 MHz clock, and the compare value to 40,000 for 50% duty. The display’s backlight current is 20 mA, so the PWM output can drive it directly if the GPIO pin is configured as a push-pull output. But the Tiva’s GPIO pins have a maximum current of 8 mA, so you need a transistor or a dedicated LED driver. A simple NPN transistor like 2N2222 with a base resistor of 1k ohm can switch the 20 mA load. The backlight LED has a forward voltage of 3.2V, so the resistor in series should be (3.3V - 3.2V) / 0.02A = 5 ohms, but a 10-ohm resistor is fine for lower current. The display’s power consumption without backlight is about 5 mA, so the total is 25 mA. The Tiva C board’s USB power can supply 500 mA, so it’s safe. The display’s FPC connector has 8 pins: pin 1 is VCC, pin 2 is GND, pin 3 is CS, pin 4 is RESET, pin 5 is DC, pin 6 is SDA, pin 7 is SCK, pin 8 is LED. The pinout is standard for many 1.77 inch modules. The ILI9163C driver chip supports a 3-wire SPI mode, but the 4-wire mode is more common. The 3-wire mode uses a 9-bit data format where the first bit is the DC bit, but the Tiva C’s SSI doesn’t support 9-bit mode, so you must use 4-wire. The display’s datasheet for the ILI9163C is available from multiple sources, and the command set is similar to the ST7735. The initialization sequence for the ST7735 is slightly different, but the ILI9163C is more common for 1.77 inch displays. The display’s resolution of 128x160 is standard for 1.77 inch diagonals, with a pixel pitch of 0.18 mm. The active area is 23.04 mm by 28.8 mm. The module size is 34 mm by 43 mm with a thickness of 2.5 mm. The weight is about 10 grams. The Tiva C board’s footprint is 53 mm by 86 mm, so the display fits on top. You can mount the display on a breadboard with the Tiva C, but the FPC connector requires a breakout. The display’s driver chip has a built-in charge pump for the LCD voltage, so no external capacitors are needed. The chip also includes a temperature sensor for gamma correction, but you don’t need to use it. The display’s sleep mode current is 0.1 mA, so you can turn off the display to save power. The Tiva C board’s low-power modes can reduce current to 1 mA, so the system can run on a battery for hours. The display’s SPI interface can be shared with other SPI devices, but you need separate CS pins. The Tiva C’s SSI0 has a single CS pin, so you can use a GPIO for the display’s CS and another GPIO for other devices. The display’s SPI speed is limited by the driver chip, not the Tiva C. The ILI9163C can handle up to 20 MHz, but the Tiva C’s SSI can go to 20 MHz only at 80 MHz system clock. The Tiva C’s SSI has a FIFO of 8 bytes, so you can fill it with 4 pixels at a time. The DMA transfer can fill the FIFO automatically. The display’s response time is 10 ms, so the pixel update rate is limited by the SPI speed. The display’s color depth is 262K colors, but the 16-bit mode reduces it to 65K colors. The human eye can see about 10 million colors, so 65K is enough for most applications. The display’s gamma correction is set by the driver chip’s registers, and you can adjust it for better contrast. The Tiva C board’s ADC can read a potentiometer to adjust the backlight brightness. The display’s viewing angle is 60 degrees, so it’s not ideal for wide-angle applications. The display’s outdoor readability is poor because the backlight is only 250 cd/m². You can use a polarizer film to improve contrast. The display’s driver chip has a test mode for manufacturing, but you don’t need it. The Tiva C board’s debug interface can be used to monitor the SPI signals with a logic analyzer. The SPI signals at 20 MHz are fast, so use a 100 MHz logic analyzer. The display’s initialization sequence can be tested with a simple pattern like a red screen. The Tiva C’s GPIO toggle speed is 40 MHz, so you can use a GPIO to trigger an oscilloscope. The display’s power-on sequence must follow the datasheet: apply VCC, then wait 10 ms, then apply RESET low for 1 ms, then high for 5 ms, then send commands. The Tiva C’s GPIO can control the RESET pin directly. The display’s backlight can be turned on after initialization. The display’s sleep mode can be entered by sending command 0x10 (sleep in) with a 5 ms delay. The display’s partial update mode can be used to update only a small area, which saves SPI bandwidth. The partial update uses the 0x2A and 0x2B commands to set the window. The display’s driver chip supports scrolling, but it’s not commonly used. The Tiva C board’s USB can be used to send images from a PC. The Tiva C’s USB device mode can be used as a virtual COM port, and you can send image data over UART. The UART speed is 115200 baud, which is slow for images, but you can compress the data. The display’s SPI speed is 20 MHz, so the UART is the bottleneck. The Tiva C’s USB host mode can read a USB flash drive with images. The Tiva C’s file system library can read FAT32 files. The image data can be stored as raw RGB565 or BMP format. The BMP format has a 54-byte header, so you need to skip it. The display’s resolution is 128x160, so a BMP file is about 40 KB plus header. The Tiva C’s flash can store the image data as a constant array. The display’s driver chip has a built-in test pattern, which you can enable by sending command 0xE0 with parameter 0x00. The test pattern shows red, green, blue, and white bars. The display’s contrast ratio is 500:1, which is typical for TFT. The display’s response time is 10 ms, so it can show video at 30 FPS. The Tiva C’s CPU can handle simple animations like a bouncing ball. The ball’s position can be updated every 33 ms. The display’s SPI data transfer must be done in a critical section to avoid corruption. The Tiva C’s interrupt disable function can be used to protect the SPI transfer. The display’s CS pin must be low during the entire transfer. The Tiva C’s SSI can be configured to automatically
Carry something made by a single pair of hands.
Browse the current season — fewer than 2,400 pieces are released each year, and many editions are already spoken for.
Shop the Collection