Docs

Micro-controllers, wireless transmission and database

Head

LCD 1602 Parallel 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

Diagram1

Diagram2

Image1

Image2

Image3

STM32CubeIDE Settings

Set PA1, PA3, PB0, PB1, PB10 and PB11 to GPIO_Output

Libraries

Inside Core/Inc Folder

lcd.h

Inside Core/Src Folder

lcd.c

Additional code on top of STM32CubeIDE generated code

/* USER CODE BEGIN Includes */
#include "lcd.h"
/* USER CODE END Includes */

  /* USER CODE BEGIN 2 */
  // Lcd_PortType ports[] = { D4_GPIO_Port, D5_GPIO_Port, D6_GPIO_Port, D7_GPIO_Port };
  Lcd_PortType ports[] = { GPIOB, GPIOB, GPIOB, GPIOB };
  // Lcd_PinType pins[] = {D4_Pin, D5_Pin, D6_Pin, D7_Pin};
  Lcd_PinType pins[] = {GPIO_PIN_0, GPIO_PIN_1, GPIO_PIN_10, GPIO_PIN_11};
  Lcd_HandleTypeDef lcd;
  // Lcd_create(ports, pins, RS_GPIO_Port, RS_Pin, EN_GPIO_Port, EN_Pin, LCD_4_BIT_MODE);
  lcd = Lcd_create(ports, pins, GPIOA, GPIO_PIN_1, GPIOA, GPIO_PIN_3, LCD_4_BIT_MODE);
  Lcd_cursor(&lcd, 0,1);
  Lcd_string(&lcd, "Nizar Mohideen");
  for ( int x = 1; x <= 200 ; x++ )
  {
    Lcd_cursor(&lcd, 1,7);
    Lcd_int(&lcd, x);
    HAL_Delay (1000);
  }
  /* USER CODE END 2 */