You are on page 1of 8

Experiment 2

“Familiarization with an STM32, the study of blink


test and implementation of a light-controlling system
using microcontrollers”
Abstract: Microcontrollers, a tiny (yet very powerful) device that changed the face of
Embedded Systems. Basic introductory experiment has done in previous lab. In this
experiment, we have expanded our knowledge about microcontroller. A STM32 series
microcontroller which is on Nucleo F401RE Board manufactured by STMicroelectronics was
learned. On the basic of the learning, a light control system was developed.

I. INTRODUCTION:
The STM32 Nucleo boards are the official Development Boards from STMicroelectronics. The
STM32 series is based on the ARM Cortex-M3 core specially designed for embedded
applications that require high performance, low cost, and low power consumption. The Boards
pinout is similar to Arduino UNO and has many other additional pins to expand performance.
This board also comes with an integrated ST-LINK/V2-1 programmer and debugger; hence it
is very easy to get started with this board. The objective of the experiment is:
1. To learn about STM32 Microcontroller.
2. To make the LED blink using ST32.
3. To Implement of a light control system using STM32.

II. THEORY & METHODOLOGY


The STM32 Nucleo-64 board provides an affordable and flexible way for users to try out new
concepts and build prototypes by choosing from the various combinations of performance and
power consumption features, provided by the STM32 microcontroller.

Fig 01: STM32 Nucleo-F401RE (Top Layout)

1|Page
Experiment 2

Features:

• STM32 microcontroller with LQFP64 package


o STM32F401RE
• Two types of extension resources
o Arduino Uno Revision 3 connectivity
o STMicroelectronics Morpho extension pin headers for full access to all
STM32 I/Os
• 32.768 kHz crystal oscillator, 24MHz or 48MHz HSE Adaptive real-time accelerator
(ART Accelerator) - 84 MHz maximum frequency
• On-board ST-LINK/V2-1 debugger/programmer with SWD connector
o selection-mode switch to use the kit as a standalone ST-LINK/V2-1
• Flexible board power supply
o USB VBUS or external source (3.3 V, 5 V, 7 - 12 V)
o Power management access point
• Three LEDs
o USB communication (LD1), user LED (LD2), power LED (LD3)
• Two push buttons: USER and RESET
• USB re-enumeration capability: three different interfaces supported on USB
o Virtual Com port
o Mass storage
o Debug port

STM32CubeIDE: STM32CubeIDE is an advanced C/C++ development platform with


peripheral configuration, code generation, code compilation, and debug features for STM32
microcontrollers and microprocessors. STM32CubeIDE includes build and stack analyzers that
provide the user with useful information about project status and memory
requirements.STM32CubeIDE also includes standard and advanced debugging features
including views of CPU core registers, memories, and peripheral registers, as well as a live
variable watch, Serial Wire Viewer interface, or fault analyzer.
Pin Configuration:

Fig 02: PIN Configuration of IDE (left) and Board (Right)

2|Page
Experiment 2

III. EXPERIMENTAL PROCEDURE


Apparatus:
1. STM32 Cube IDE
2. STM32 Nucleo-F401RE Board
3. LED lights (RED, GREEN, or YELLOW)
4. Three 270 ohms resistors and
5. Jumper wires
A very basic task was completed utilizing LED Blink to gain an understanding of the STM32
project building process. The procedure was started with STMIDE and Nucleo-F401RE Board
have selected. The D13 PIN on the Nucleo-F401RE Board has an integrated LED. In STMIDE
before generate code, the IDE software PIN configuration have specified at where the output
is generated. Then, a C language code has generated in main.c.

Fig 03: PIN configuration for LED Blink

In STMIDE, PIN D13 is defined as PA5. To specify this PIN as output, GPIO_OUTPUT have
selected.
Code: In While loop section, HAL_GPIO_TogglePin (GPIO_TypeDef *GPIOx, uint16_t
GPIO_Pin) function is used to Specifies the pins to be toggled. And HAL_Delay (uint32_t
Delay) function is provided minimum delay (in milliseconds) based on variable incremented.

3|Page
Experiment 2

Fig 04: Code for LED Blink

The project has built and for hardware implementation the code has transfer to the Nucleo
F401-RE Board from the Debug option.

Fig 05: Build Project and Debug

As, no board was connected yet the debug as option was showing none applicable. The specific
board shows in this section to select and upload the code.
Using this same procedure, a light-controlling system and traffic control system have
developed. Both practical and simulated outcomes are discussed in the results section.

4|Page
Experiment 2

Light Control System:

Fig 06: Code for Light Control System

IV. RESULTS
Practical Results:
LED Blink:

Fig 07: Implementation of LED Blink

A simple circuit has been developed on a breadboard to see the LED blink. The LED was
powered by +3.3V, and to complete the circuit, the other end was grounded. The LED on the
board that is linked to PIN D13 is represented by this LED. The toggle or Blink operation of
LED has identified.

5|Page
Experiment 2

Light Control System:

Fig 08: Implementation of Light Control System

The board's Green LED was the first to activate. Red, Yellow, and Green are then displayed in
order. Each delay time has an impact on the glowing time. The circuit was running successfully
based on the function written in code file.
Simulation Results:
LED Blink & Light Control System:

Fig 09: Simulation of LED Blink(Left) & Light Control System(Right)


On proteus software, the equivalent LED Blink and Light Control system circuit was designed. The
hex. File was uploaded on this STM32F401RE library. There is no difference in the practical and
simulated outcome.

6|Page
Experiment 2

Report Questions:
Traffic Control System Simulation:

Fig 10: Code for Traffic Control System

Fig 11: Simulation of Traffic Control System

7|Page
Experiment 2

V. Discussion and Conclusion


The purpose of the experiment is to discover more about microcontrollers. The STM32 Nucleo-
F401RE Board was examined to better comprehend a microcontroller's capabilities. After
learning the fundamentals of STM32, a simple Light control & traffic control system was
designed. The code was developed using appropriate functions in accordance with the design,
and the specifics of the functions were thoroughly reviewed. Code was uploaded by following
the steps. The process operates well in both hardware implementation and simulation. The
experiment's primary goals were accomplished.
Since most of the modern electronics requires more compute power, memory and peripherals
set, the popularity of 32-bit microcontrollers is increasing among designers. One of the most
commonly used 32-bit devices are the STM32 Microcontrollers from ST Microelectronics
which is based on the successful ARM core processors. STM32 is much more powerful than
AVR. Industrial PLCs and other complex devices need the extra processing power and larger
memory capacity, and having that extra power makes complex software easier to write and
maintain - which makes it more reliable. The knowledge gained from this foundational
experiment will serve as a valuable resource for further applications.

VI. References
[1] NUCLEO-F401RE. (n.d.). STMicroelectronics. Retrieved October 13, 2022, from
https://www.st.com/en/evaluation-tools/nucleo-f401re.html
[2] STM32 Nucleo F401RE Development Board. (n.d.). Components101. Retrieved October
13, 2022, from https://components101.com/microcontrollers/stm32-nucleo-f401re-
pinout-datasheet
[3] STMicroelectronics STM32F401RE. (n.d.). Retrieved October 13, 2022, from
https://www.keil.com/dd/chip/7542.htm
[4] American International University-Bangladesh. (n.d.). Familiarization with an STM32,
the study of blink test and implementation of a light-controlling system using
microcontrollers.: MES Student lab manual 02.

8|Page

You might also like