Step by Step Guidance for Interfacing 16X2 LCD Without I2C

by Jasleen_kaur in Circuits > Microcontrollers

264 Views, 0 Favorites, 0 Comments

Step by Step Guidance for Interfacing 16X2 LCD Without I2C

Screenshot 2024-05-07 010949.png
Screenshot 2024-05-07 011002.png

Introducing the STM32 Black Pill, a compact and robust microcontroller board leveraging the power of the STM32F103C8T6 ARM Cortex-M3 processor. With its extensive range of peripherals like GPIOs, UARTs, SPIs, I2Cs, and more, it proves its versatility across various applications. This tutorial will enlighten us on utilizing the STM32 Black Pill and STM Cube IDE to exhibit the text "Name" on a 16x2 LCD display. Interestingly, we'll accomplish this without relying on an I2C module, but by harnessing the potential of HAL (Hardware Abstraction Layer) programming. Embrace this exciting journey of discovery!

Supplies

  • STM32 Black Pill board
  • 16x2 LCD module
  • Jumper wires
  • STM Cube IDE
  • STM32 Cube Programming
  • C-type Cable

Creating a New Project

Screenshot 2024-04-10 153910.png
  • Open STM32CubeIDE>Goto files>click New>select STM32 Project


Adding MCU/MPU Selector Features for STM32 Project

Screenshot 2024-05-07 021736.png
Screenshot 2024-05-07 021756.png
Screenshot 2024-05-07 022842.png
  • Enter the Commerical Number of STM32 you want to work with( used Commerical Number in this project:STM32F401CCU6)
  • Select the required type of configuration of STM32.
  • Then click next.
  • A dialogue box appears >type the name of the project
  • The project file is created to work on it.


Pinout Configuration

Screenshot 2024-05-07 022432.png
Screenshot 2024-05-07 022453.png
  • Select RCC from System Core.
  • Select the Bypass Clock Source in High speed clock.
  • Select the Pins to which the LCD pins are connected and set them as "GPIO_Output".


Clock Configuration

Screenshot 2024-05-07 022506.png
  • Select clock configuration.
  • Select HSE and PLLCLK in PLL Source MUX & System Clock MUX respectively.
  • Then select resolve clock issues


Generating the Code

Screenshot 2024-05-07 022611.png
  • Select the project from dialogue box.
  • Select generate code option from it.
  • The code gets generated.


Creating .Ioc File

Screenshot 2024-05-07 022519.png
Screenshot 2024-05-07 022547.png
Screenshot 2024-05-07 023214.png
  • Select the file you working on (from the left side)>right click on it.
  • A option box appears>select properties.
  • Then the dialogue box opens >select the C/C++ Build (from left side of it).
  • Select settings>MCU Post build Ouput
  • Choose the options shown in the image.
  • Then apply and close.
  • The .ioc file is created


Main.c

Screenshot 2024-05-07 022632.png
  • Select the core from the File .
  • Go to Src>select main.c.
  • Main.c gets open to write code.(A code is generated already to help you in the configuration and to identify pin numbers you selected as output pins)


Writing Code

Screenshot 2024-05-07 023343.png
Screenshot 2024-05-07 023353.png
Screenshot 2024-05-07 023404.png
  • Write the according to the photograph and in while loop.
  • Change the Chitkara Univeristy with your name.

Debug the Code

Screenshot 2024-04-24 200908.png
  • Select Build >select option 1.debug


Copying the Path Of.elf File

Screenshot 2024-05-07 022707.png
  • After debuging the ;if any error arises then remove all the error and if no error comes then go to .ioc file.
  • Select .ioc file right click on it ,a option box appears.
  • Select show in>system explorer.
  • Files will be opened.
  • Select the .elf file and copy its path.


Adding the .elf on STM32CubeProgramer

Screenshot 2024-04-24 012614.png
  • Open the STM32CubeProgrammer.
  • Select the Open file option >paste the path copied of .elf file there.
  • File is added.


Breadboard Connection

Screenshot 2024-05-07 010949.png
  • Connect the LCD with STM32 Black Pill similarly to the given connections.

Connect the STM32

Screenshot 2024-04-24 202245.png
  • Connect the STM32 Black pill with Laptop.
  • Connect it with STM32CubeProgrammer by USB.
  • BOOT the STM32 to connect it.
  • After connecting click on Connect


Download the File

Screenshot 2024-04-24 201740.png
  • Goto Download>paste the copied of .elf file here also
  • Click on Start Automatic Mode.


LCD Start Interfacing

Screenshot 2024-05-07 024303.png
  • Disconnect the STM32.
  • You will see your name on the LCD.