Docs

Micro-controllers, wireless transmission and database

Head

ST7735 Display with Blue Pill using STM32CubeIDE

Prerequisites

This project assumes you have already installed STM32CubeIDE. You need to have previously done a basic blink sketch with blue-pill using STM32CubeIDE. I have made a complete video from installing STM32CubeIDE to LED blink program. You can watch it by clicking this link. https://www.youtube.com/watch?v=kXg467nVd_A

Wiring Diagram

Diagram

Image1

Image2

STM32CubeIDE Settings

Click RCC → High Speed Clock (HSE) to Crystal/Ceramic Resonator

Click Clock Configuration tab → HCLK (MHz) to 72

Click Pinout and Configuration tab

Click connectivity → Click SPI1

For Mode select Half-Duplex Master

Configuration → Parameter Settings

Change prescalar (for Baud rate) to 32

Set PB0, PB1 AND PB10 to GPIO_Output

Libraries

Taken from https://github.com/afiskon/stm32-st7735

Inside Core/Inc Folder

fonts.h

GFX_FUNCTIONS.h

st7735.h

Inside Core/Src Folder

fonts.c

GFX_FUNCTIONS.c

st7735.c

Additional code on top of STM32CubeIDE generated code (main.c)


/* USER CODE BEGIN Includes */
#include <string.h>
#include "st7735.h"
#include "GFX_FUNCTIONS.h"
#include "fonts.h"
/* USER CODE END Includes */
/* USER CODE BEGIN 2 */
ST7735_Init();
/* USER CODE END 2 */
/* USER CODE BEGIN WHILE */
while (1)
{
  ST7735_FillScreen(ST7735_BLACK);
  ST7735_WriteString(0, 0, "MicroPeta", Font_7x10, ST7735_RED, ST7735_BLACK);
  ST7735_WriteString(0, 3*10, "by Nizar   Mohideen", Font_11x18, ST7735_GREEN, ST7735_BLACK);
  ST7735_WriteString(0, 3*10+3*18, "March  2023", Font_16x26, ST7735_BLUE, ST7735_BLACK);
  HAL_Delay(3000);
  ST7735_FillScreen(ST7735_BLACK);
  drawCircle(50, 55, 20, ST7735_GREEN);
  drawCircle(50, 55, 21, ST7735_GREEN);
  drawCircle(50, 55, 22, ST7735_GREEN);
  drawCircle(50, 55, 23, ST7735_GREEN);
  drawCircle(50, 55, 24, ST7735_GREEN);
  drawCircle(50, 55, 25, ST7735_RED);
  drawCircle(50, 55, 26, ST7735_RED);
  drawCircle(50, 55, 27, ST7735_RED);
  drawCircle(50, 55, 28, ST7735_RED);
  HAL_Delay(4000);
  /* USER CODE END WHILE */