ST7735 1.8″ TFT display with PIC16F877A example – CCS C

Interfacing PIC16F877A with ST7735 1.8″ SPI TFT Color Display
PIC16F877A ST7735 TFT display hardware circuit

After interfacing 1.8″ TFT display with PIC18F4550 microcontroller at the link below, now let’s see how to make the same interfacing of this SPI TFT display with PIC16F877A microcontroller.
Interfacing PIC18F4550 with 1.8″ TFT display

For this project we need a CCS C compiler library for the ST7735 TFT display which can be found in the link below with some descriptions:
ST7735 SPI TFT Display Driver for CCS PIC C compiler

Or you can just download it directly from the following link:
ST7735 SPI TFT Display Driver

Put the downloaded C file in your project folder.

Required Components:

  • PIC16F877A Microcontroller
  • ST7735R (or ST7735S) 1.8″ SPI TFT Display
  • 8MHz Crystal oscillator
  • 2 x 22pF Capacitors
  • 10K Resistor
  • 5 x 1K Resistors (If the system is 3.3V there is no need for these resistors)
  • Power Supply Source (+5V or +3.3V)
  • Breadboard
  • Jumper Wires

Interfacing ST7735 1.8″ TFT display with PIC16F877A circuit:

PIC16F877A ST7735 SPI TFT display circuit

The system power supply is 5V and if you are using a microcontroller TFT display of 3.3V remove all the 1K resistors (5 resistors) from the circuit and connect the TFT display directly to the microcontroller.
The microcontroller runs with 8MHz crystal oscillator, if you want to get better result (fast) use a crystal with higher frequency up to 20MHz.

ST7735 1.8″ TFT display with PIC16F877A example CCS C code:
PIC16F877A hardware SPI module is used to send data to the TFT display. SPI module uses the following pins:
SDI (RC4): data input pin (not used in this project)
SCK (RC3): clock line
SDO (RC5): data output
// TFT module connections
#define TFT_CS   PIN_D1
#define TFT_DC   PIN_D0
#define TFT_SPI_HARDWARE
 // End TFT module connections
My TFT display is ST7735R Black Tap (ST7735S) and for initializing this type of TFT display I used the following line:
TFT_BlackTab_Initialize();
If you have a TFT display with green or red tabs or a TFT with ST7735B controller read the driver topic above.
Note that green, red and black tabs have the same controller ST7735R.
fillScreen(ST7735_BLACK);              // Fill all the screen with black
The following line means that the TFT willl display a text called txt starting from coordinates (0, 30) with red color, black background and size 1.
drawtext(0, 30, txt, ST7735_RED, ST7735_BLACK, 1);
The following line will display a white straight horizontal line starting from coordinates (0, 53).
drawFastHLine(0, 53,  _width,  ST7735_WHITE);
This code is tested with CCS C compiler versions 4 and 5.

ST7735 1.8″ TFT display with PIC16F877A example video:
Simple hardware circuit of this example.

Leave a Reply

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