Interfacing PIC18F46K22 MCU with ST7735 TFT – Rotation Test Example

Опубликовано: 28 Июль 2026
на канале: Electronics Developer
381
like

-------------------------
📌Introduction
-------------------------
This is another example that shows how to interface PIC18F46K22 microcontroller with ST7735 SPI TFT display. In this project I’m going to do a simple rotation test to the ST7735 TFT display.This post shows how to interface Microchip PIC18F46K22 8-bit microcontroller with ST7735 TFT display (128×160 pixel resolution).
The ST7735 TFT display is a color display that uses SPI protocol, it’s low cost and easy to use.
This module works with 3.3V only, connecting it directly to a 5V system will not work and may damage its controller circuit!

-------------------------
📌Circuit Design
-------------------------
The ST7735S shown in project circuit diagram has 8 pins: (from right to left): RST (reset), CS (chip select), DC (or D/C: data/command), DIN (data in), CLK (clock), VCC, BL (back light) and Gnd (ground).The ST7735 display module is supplied with 5V. GND pin is connected to circuit ground, VCC and BL pins are connected to circuit +5V.

The PIC18F46K22 microcontroller has 2 hardware SPI modules (MSSP1 and MSSP2 modules).
In this project SPI1 module is used with SCK1 on pin RC3 (#18) and SDO1 (MOSI) on pin RC5 (#24). SCK1 and SDO1 pins of the PIC18F46K22 MCU are respectively connected to CLK and DIN pins of the ST7735S display module.
SCK: Serial Clock.
SDO: Serial Data-Out, synonym for MOSI.
MOSI: Master-Out Slave-In.

All PIC18F46K22 MCU output pins are 5V, connecting a 5V pin directly to the ST7735 display board may damage its controller circuit. To avoid that, I connected each control line of the display to the microcontroller through 1k ohm resistor.

So, the ST7735 display is connected to the PIC18F46K22 MCU as follows (each one through 1k resistor):
RST pin is connected to pin RD0 (#19),
CS pin is connected to pin RD1 (#20),
D/C pin is connected to pin RD2 (#21),
DIN pin is connected to pin RC5 (#24),
CLK pin is connected to pin RC3 (#18).

In this project the PIC18F46K22 microcontroller runs with its internal oscillator @ 32 MHz, MCLR pin is configured as an input pin.

-------------------------
📌 Tags
-------------------------
#pc18f46k22 #st7735 #display

-------------------------
📌 The Code
-------------------------
The following C code is for CCS C compiler, it was tested with versions 5.051 and 5.083.

To be able to compile project C code with no error, 2 libraries are required:
The first library is a driver for the ST7735 TFT display, its full name (with extension) is ST7735.c,
1. ST7735 TFT display library for CCS C compiler

The second library is graphics library, its full name is GFX_Library.c,
2. Graphics library for CCS C compiler

after the download of the 2 library files, add both of them to the project folder.Source Code give in comment section.

📌 Tune With us so you never miss any update
---------------------------------------------------------------------------------------------------------------------------------------------------------
🏷️Telegram : https://t.me/electronicsdeveloper
🏷️Facebook :   / electronicsdeveloper  
🏷️Instagram :   / electronics_developer  
🏷️Tweeter : https://twitter.com/Electronics_Dev?s=09
🏷️LinkedIn :   / electronics-with-shreyash  
🏷️Pinterest :   / electronics_developer  

Copyright Disclaimer under Section 107 of the copyright act 1976
----------------------------------------------------------------------------------------------------------------------------------------------------------
Copyright Disclaimer under Section 107 of the copyright act 1976, allowance is made for fair use for purposes such as criticism, comment, news reporting, scholarship, and research. Fair use is a use permitted by copyright statute that might otherwise be infringing. Non-profit, educational or personal use tips the balance in favour of fair use.

----------------------------------------------------------------------------------------------------------------------------------------------------------
About Electronics Developer : YouTube certified creative essentials and asset monetization
----------------------------------------------------------------------------------------------------------------------------------------------------------