Interfacing PIC MCU with ST7735R SPI TFT – mikroC Projects

This post shows how to use mikroC library for ST7735R TFT with PIC16F887 microcontroller where hardware SPI module of the PIC16F887 is used in this example. A simulation of this example using Proteus is provided at the end of the post.

The ST7735 uses SPI communication protocol and the PIC16F887 has one SPI module where the PIC16F887 is the master device and the TFT is the slave device.
Generally the SPI protocol has 3 lines: SCK (serial clock), SDI (serial data in) and SDO (serial data out) but for interfacing the ST7735 TFT we use only 2 lines: SCK and SDO.
The PIC16F887 has one SPI module with SCK mapped to RC3 pin (#18) and SDO mapped to RC5 (#24).

To be able to compile the mikroC code below we need a small file named ST7735_TFT.c , this file is the driver (library) of this type of TFT. The library file download link can be found at the end of this topic:
ST7735R SPI TFT driver for mikroC PRO for PIC

After downloading the driver file just put it in the project folder.

Hardware Required:

  • PIC16F887 microcontroller   —> datasheet
  • ST7735 1.8″ TFT display
  • 20MHz crystal oscillator
  • 2 x 22pF ceramic capacitor
  • 5 x 1k ohm resistors
  • Protoboard
  • 5V Power supply source
  • Jumper wires
  • PIC Microcontroller programmer (PICkit 2, PICkit 3…)

Interfacing PIC microcontroller with ST7735R TFT circuit:
Example circuit diagram is shown below.

PIC16F887 with ST7735R mikroC

(All grounded terminals are connected together)

In this project I used 20MHz crystal oscillator which is the maximum speed of the PIC16F887, this gives the highest SPI data transfer rate (5Mbit/s). Lower crystal frequencies can be used or even the internal oscillator of the microcontroller.
5 x 1k ohm resistors are needed for the all control lines because the ST7735R works with 3.3V and the PIC16F887 works with 5V , it may be damaged if it connected directly to the microcontroller. The TFT is supplied with 5V because its board contains AMS1117 3.3V voltage regulator.

There is no pull-up resistor connected to MCLR pin because it is configured to work as a digital input pin (in the software).

Interfacing PIC microcontroller with ST7735R TFT mikroC code:
As mentioned above, in order to compile the mikroC code below without any error we have to add the driver source file of the ST7735R to the project folder, the full name of this file is ST7735_TFT.c and its download link can be found in the page with the link above.

Configuration words:
CONFIG2: 0x0700

Full mikroC code:

PIC16F887 + ST7735R Proteus simulation video:

PIC16F887 + ST7735R Proteus simulation file download:

Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

6 thoughts on “Interfacing PIC MCU with ST7735R SPI TFT – mikroC Projects”

  1. Hi I’m sorry but I couldn’t find the library that you said, where I can download it? And how I can install it into Micro C v.7.1 for no errors during compile??

Leave a Comment

Your email address will not be published. Required fields are marked *

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

Scroll to Top