LAB: GPIO Digital InOut 7-segment
Date: 2023-09-22
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(main*.c, ecRCC.h, ecGPIO.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 1: Connecting 7-Segment Display
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
The popular BCD 7-segment decoder chips are 74LS47 and CD4511.
Instead of using the decoder chip, we are going to make the 7-segment decoder with the MCU programming.
Do not use the 7-segmment decoder
Connect the common anode 7-segment with the given array resistors.
Apply VCC and GND to the 7-segment display.
Apply 'H' to any 7-segment pin 'a'~'g' and observe if that LED is turned on or off
example: Set 'H' on PA5 of MCU and connect to 'a' of the 7-segment.
Connection Diagram
Circuit diagram
You need to include the circuit diagram
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 2: Display 0~9 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.
2. 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
You can refer to an example code of 7-segment control
ecGPIO.h
First, check if every number, 0 to 9, can be displayed properly
Then, create a code to display the number from 0 to 9 with each button press. After the number '9', it should start from '0' again.
Configuration
Fill in the table
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
Problem 3: Using both 7-Segment Decoder and 7-segment display
Procedure
Now, use the decoder chip (74LS47). Connect it to the bread board.
Then, you need only 4 Digital out pins of MCU to display from 0 to 9.
Connection Diagram
Circuit diagram
You need to include the circuit diagram
Work on the same project and code.
i.e. : project “LAB_GPIO_7segment”. and source file named as “LAB_GPIO_7segment.c”
First, check if every number, 0 to 9, can be displayed properly
Then, create a code to display the number from 0 to 9 with each button press. After the number '9', it should start from '0' again.
Configuration
Reference
Complete list of all references used (github, blog, paper, etc)
Troubleshooting
(Option) You can write Troubleshooting section
Last updated