GlobalLogic
Embedded Starter
Kit
LEDs and Buttons
Training 02
Bare Metal
Trainings
Contents
▪ Assignments and Goals
▪ Theory
▪ Practice
▪ Individual task
28.09.2020 17:07 Bare Metal – Training 02 2
Assignments and Goals
• Create firmware that works with LEDs and
buttons
• Learn LED and button HW background
(how it’s working)
• Learn GPIO I/O basics
• Learn GPIO_EXTI interrupts
28.09.2020 17:07 Bare Metal – Training 02 3
LEDs schematics
28.09.2020 17:07 Bare Metal – Training 02 4
Buttons schematics
28.09.2020 17:07 Bare Metal – Training 02 5
General-purpose I/Os (GPIO)
28.09.2020 17:17 Bare Metal – Training 02 6
General-purpose I/Os (GPIO)
GPIO pin can be configured as
• Input/Output pin with/without
pull up/down resistors (digital)
• ADC/DAC pin (analog)
• Alternative function
28.09.2020 17:07 Bare Metal – Training 02 7
General-purpose I/Os (GPIO)
28.09.2020 17:07 Bare Metal – Training 02 8
General-purpose I/Os (GPIO)
28.09.2020 17:07 Bare Metal – Training 02 9
General-purpose I/Os (GPIO)
28.09.2020 17:07 Bare Metal – Training 02 10
General-purpose I/Os (GPIO)
28.09.2020 17:07 Bare Metal – Training 02 11
General-purpose I/Os (GPIO)
28.09.2020 17:07 Bare Metal – Training 02 12
General-purpose I/Os (GPIO)
28.09.2020 17:07 Bare Metal – Training 02 13
General-purpose I/Os (GPIO)
28.09.2020 17:47 Bare Metal – Training 02 14
Practice
• Create new Keil Project
(see Pract_01 for details)
• Set HW settings (with CubeMX)
– PA15 – GPIO_Input (SW2)
– PD15 – GPIO_Output (LED6 Blue)
• Complete main while loop with code
provided
28.09.2020 17:07 Bare Metal – Training 02 15
Practice
28.09.2020 17:07 Bare Metal – Training 02 16
Practice
28.09.2020 17:07 Bare Metal – Training 02 17
Add source code
• Modify source code with
snippets from following file
• Compile
• Flash
• Press “SWT2” button to test
FW
• What main disadvantage of
this solution?
28.09.2020 17:22 Bare Metal – Training 02 18
Main loop timeline
28.09.2020 17:07 Bare Metal – Training 02 19
Pooling
Add interrupts
28.09.2020 17:07 Bare Metal – Training 02 20
Enable interrupts
28.09.2020 17:07 Bare Metal – Training 02 21
Modify source code
• Modify source code with
snippets from following file
• Compile
• Flash
• Press “SWT2” button to test
FW
• Issue disappeared?
28.09.2020 17:32 Bare Metal – Training 02 22
Main loop + IRQ timeline
28.09.2020 17:44 Bare Metal – Training 02 23
Interrupts
Individual task
• LED blink frequency change using switches
• Blinking LED number change using switches
28.09.2020 17:44 Bare Metal – Training 02 24

Bare metal training_02_le_ds_and_buttons