LAB: GPIO Digital InOut
LAB: GPIO Digital InOut
Date: 2023-09-19
Author/Partner:
Github: repository link
Demo Video: Youtube link
PDF version:
Introduction
In this lab, you are required to create a simple program that toggle multiple LEDs with a push-button input. Create HAL drivers for GPIO digital in and out control and use your library.
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:
LEDs x 3
Resistor 330 ohm x 3, breadboard
Software
Keil uVision, CMSIS, EC_HAL library
Problem 1: Create EC_HAL library
Procedure
Create the library directory \repos\EC\lib\
.
Save your header library files in this directory. See here for detail.
DO NOT make duplicates of library files under each project folders
Create your own library for Digital_In and Out : ecGPIO.h, ecGPIO.c
Use the provided
ecRCC.h
andecRCC.c
Modify
ecGPIO.c
,ecGPIO.h
ecRCC.h (provided)
ecGPIO.h
Example code
Problem 2: Toggle LED with Button
Procedure
Create a new project under the directory
\repos\EC\LAB\
The project name is “LAB_GPIO_DIO_LED”.
Name the source file as “LAB_GPIO_DIO_LED.c”
Use the example code provided here.
2. Include your library ecGPIO.h, ecGPIO.c in \repos\EC\lib\
.
You MUST write your name in the top of the source file, inside the comment section.
3. Toggle the LED by pushing the button.
Push button (LED ON), Push Button (LED OFF) and repeat
Configuration
Button (B1) | LED |
---|---|
Digital In | Digital Out |
GPIOC, Pin 13 | GPIOA, Pin 5 |
PULL-UP | Open-Drain, Pull-up, Medium Speed |
Code
Your code goes here:
Explain your source code with necessary comments.
Sample Code
Discussion
Find out a typical solution for software debouncing and hardware debouncing.
What method of debouncing did this NUCLEO board use for the push-button(B1)?
Problem 3: Toggle LED with Button
Procedure
Create a new project under the directory
\repos\EC\LAB\
The project name is “LAB_GPIO_DIO_multiLED”.
Name the source file as “LAB_GPIO_DIO_multiLED.c”
You MUST write your name in the top of the source file, inside the comment section.
Include your library ecGPIO.h, ecGPIO.c in
\repos\lib\
.Connect 4 LEDs externally with necessary load resistors.
As Button B1 is Pressed, light one LED at a time, in sequence.
Example: LED0--> LED1--> …LED3--> …LED0….
Configuration
Button | LED |
---|---|
Digital In | Digital Out |
GPIOC, Pin 13 | PA5, PA6, PA7, PB6 |
PULL-UP | Push-Pull, Pull-up, Medium Speed |
Circuit Diagram
Circuit diagram
You need to modify the circuit diagram
Code
Your code goes here
Explain your source code with necessary comments.
Results
Experiment images and results
Show experiment images /results
Add demo video link
Discussion
Find out a typical solution for software debouncing and hardware debouncing. What method of debouncing did this NUCLEO board use for the push-button(B1)?
Answer discussion questions
Reference
Complete list of all references used (github, blog, paper, etc)
Troubleshooting
(Option) You can write a Troubleshooting section
Last updated