You can access the source code files via this link. in this project
This project integrates the STM32 microcontroller with the 74HC595 shift register to develop a sophisticated LED bar-graph display system. Leveraging the STM32‘s GPIO pins and SPI interface, the project efficiently manages the 74HC595 to control a series of LEDs configured in a bar-graph layout.
Exploring the Functionality of the 74HC595 Shift Register:Each output of the 74HC595 is intricately connected to an individual LED, thus forming the cohesive bar-graph display. By serially shifting data into the 74HC595 and subsequently latching it to the output registers, the STM32 orchestrates precise control over the illumination of each LED within the bar-graph structure.
Understanding the Role of 74HC595 as the Master Conductor:The 74HC595 shift register functions as the master conductor, intricately orchestrating the flow of data with finesse and accuracy. Its capability to seamlessly accept data in serial format and output it in parallel establishes the foundational framework for controlled and synchronized actions within the system. Whether tasked with managing LED screens or controlling multiple peripheral devices, the 74HC595 emerges as a versatile component within the embedded landscape.
To commence this project, our first step is to configure the STM32 in SPI Transmit-only master mode. This setup is crucial for establishing seamless communication with the 74HC595 shift register. Following that, we’ll configure the appropriate pins, such as PB1, specifically pin 12 (LATCH), as OUTPUT to ensure accurate control over peripheral devices interfaced with the shift register
Step One:- Open CubeMX & Create New Project Choose The Target MCU STM32F103C6 & Double-Click Its Name
- Go To The Clock Configuration & Set The System Clock To 8MHz
Configuration for the
GPIO
Mode:
- Configure The GPIO Pin PA4 as Output Pin (CSPin)
Configuration for the
SPI
Mode:
- In the Categories tab, select the SPI1 & Transmit Only Master
- In the Parametre settings set [ Prescaler (for Baud Rate) =2 && Clock Polarity = LOW && Clock Phase = 1 Edge ]
- Generate The Initialization Code & Open The Project In CubeIDE
- Write The Application Layer Code
- Click on Pick Device
- Search for STM32F103C6 & SW-SPDT(switch) & LED_RED BLUE and YELLOW
- Click on Virtual Instruments Mode then choose VIRTUAL TERMINAL
- Click on Terminal Mode then choose (DEFAULT & POWER &GROUND)
- finally make the circuit below and start the simulation
If you have any questions or suggestions don't hesitate to leave a comment below
Comments