ST7735 1.8″ TFT Display with STM32
In this tutorial, I will cover how to interface ST7735 1.8″ TFT Display with STM32, and to do so, I will use the SPI peripheral of STM32.
This particular display uses 8 pins for controlling the display, and the pins are shown below
1. LED :: Backlight -> Connect to 3.3V
2. SCK :: Serial clock input -> connect to SPI SCK pin
3. SDA :: Serial data input -> Connect to SPI MOSI pin
4. DC :: Data/Command selection -> Connect to PA9
5. RESET :: Reset -> Connect to PC7
6. CS :: Chip Select -> Connect to PB6
7. GND :: Ground -> GND
8. VCC :: Power Supply -> 3.3V
I have selected SPI for the purpose, and I am keeping the Baud Rate around 5 MB/s. You can test higher baud rates also.
Other than SPI pins, we need to select three more pins as output. I have selected PB6 for CS, PC7 for RESET, and PA9 for DC. You are free to choose any other pins also, whatever suits the requirement
Other than this, you also need to include ST7735.h and ST7735.c in the project folder.
That’s all the setup needed here. Let’s take a look at some part of the code
First of all we need to set the parameters according to our setup. All the changes needed to made are only in the ST7735.h file
Change the SPI handler according to your setup
If you are not using the default pins, Change them above
Also, if you have any other variant of ST7735, you need to uncomment the respective define above.
Change the width and the height parameters too
Below is the main function
You can see the output of the above code in the result section