LAB: GPIO Digital InOut 7-segment
LAB: GPIO Digital InOut 7-segment
Date: 2024-09-1
Author/Partner:
Github: repository link
Demo Video: Youtube link
PDF version:
Introduction
In this lab, you are required to create a simple program to control a 7-segment display to show a decimal number (0~9) that increases by pressing a push-button.
You must submit
LAB Report (*.pdf)
Zip source files(LAB***.c, ecRCC2.h, ecGPIO2.h etc...).
Only the source files. Do not submit project files
Requirement
Hardware
MCU
NUCLEO-F411RE
Actuator/Sensor/Others:
7-segment display(5101ASR)
Array resistor (330 ohm)
decoder chip(74LS47)
breadboard
Software
Keil uVision, CMSIS, EC_HAL library
Exercise
Fill in the table
Problem 0: Connection of 7-Segment Display and Decoder
Procedure
Review 7-segment Decoder and Display from Digital Logic lecture.
Read here: 7-segment tutorial
Read here: How to connect 7-segment decoder to MCU
1. 7-segment display connection
First, connect the common anode 7-segment display with the given array resistors.
Then, apply VCC and GND to the 7-segment display.
Check that all LEDs of 7-segment work properly
Give 'H' signal to each 7-segment pin of 'a'~'g' . Observe if that LED is turned ON or OFF
Example: Connect VCC to all 'a'~'g' pins
2. BCD 7-segment decoder connection
The popular BCD 7-segment decoder chip is 74LS47. With the BCD chip, you need only 4 DOUT pins of MCU to display from 0 to 9.
Connect the decoder chip (74LS47) on the bread board.
Then, Check that the decoder chip works properly
Supply a combination of VCC/GND to the pins of 'A'~'D' of the decoder.
Check if the 7-segment LED display shows the correct number
Connection Diagram
Circuit diagram
You need to include the circuit diagram in the report
Discussion
Draw the truth table for the BCD 7-segment decoder with the 4-bit input.
Answer discussion questions
What are the common cathode and common anode of 7-segment display?
Answer discussion questions
Does the LED of a 7-segment display (common anode) pin turn ON when 'HIGH' is given to the LED pin from the MCU?
Answer discussion questions
Problem 1: Display a Number with Button Press
Procedure
Create a new project under the directory
\repos\EC\LAB\LAB_GPIO_7segment
The project name is “LAB_GPIO_7segment”.
Create a new source file named as “LAB_GPIO_7segment.c”
Refer to the sample code
You MUST write your name on the source file inside the comment section.
Include your updated library in
\repos\EC\lib\
to your project.
ecGPIO.h, ecGPIO.c
ecRCC.h, ecRCC.c
Declare and Define the following functions in your library
num: 0 to 9 only (unsigned)
Configure and connect the MCU to the circuit
First, check that every number, 0 to 9, can be displayed properly
Then, create a code that increase the displayed number from 0 to 9 with each button press.
After the number '9', it should start from '0' again.
Configuration
Configure the MCU
Code
Your code goes here: ADD Code LINK such as github
Explain your source code with necessary comments.
Results
Experiment images and results
Show experiment images /results
Add demo video link
Discussion
Analyze the result and explain any other necessary discussion.
Problem 2: Program BCD-7-segment decoder
Instead of using the decoder chip, we are going to make the 7-segment decoder with the MCU programming.
Do not use the 7-segment decoder for this problem
Procedure
Use the same project and source file.
Include your updated library in
\repos\EC\lib\
to your project.
ecGPIO.h, ecGPIO.c
ecRCC.h, ecRCC.c
Declare and Define the following functions in your library
num: 0 to 9 only (unsigned)
Configure and connect the MCU to the circuit
First, check that every number, 0 to 9, can be displayed properly
Then, create a code that increases the displayed number from 0 to 9 with each button press.
After the number '9', it should start from '0' again.
Configuration
Configure the MCU
Code
Your code goes here: ADD Code LINK such as github
Explain your source code with the necessary comments.
Connection Diagram
Circuit diagram
You need to include the circuit diagram
Results
Experiment images and results
Show experiment images /results
Add demo video link
Discussion
Analyze the result and explain any other necessary discussion.
Reference
Complete list of all references used (github, blog, paper, etc)
Troubleshooting
(Option) You can write Troubleshooting section
Last updated