Professional Documents
Culture Documents
Abstract—The experiment primarily aims to demonstrate the A microcontroller’s CPU reads the program code from
use of Hardware Abstraction Layer (HAL) approach in memory one at a time and each instruction gets decoded. These
programming microcontroller units (MCU’s) and compare it to binary codes would tell the CPU on what to do, as it performs
the Cortex Microcontroller Software Interface Standard (CMSIS) operations on the data values. The CPU reads instruction codes
approach. The methodology of the experiment mainly revolves from a memory sequentially, which are from sequential memory
around blinking the LED peripheral of the MCU using HAL addresses, unless instructed to jump or skip a code. For example,
approach. Blinking rate of the LED was measured with its if the instruction memory starts at address 0000, then the CPU
corresponding delay time. The relationship between both would read and execute the instruction stored at this specific
parameters was determined through analyzing its graph. It was
address [1]. It would be assumed that the processing will
observed from the data measured and calculated that blinking
rate is directly proportional to the proportionality constant k and
continue to execute codes from addresses 0001, 0002, 0003, and
inversely proportional to the delay time. In addition, so on, unless instructed otherwise. It is then generalized that
proportionality constant k from both parameters must be there is a sequence of operations being strictly followed when
determined in order to predict the behavior of the LED with each programming a series of machine-language instructions. As
corresponding delay time increment. It was concluded that HAL- numerous complex instructions from programs already gets
based programming approach provides ease in programming relayed to the MCU, the emergence of embedded systems would
instructions to the microcontroller as it generally requires lesser come into use.
coding compared to that of CMSIS. Furthermore,
STM32CubeMX graphical tool provides a wide-variety of
An embedded system is a combination of both hardware and
functions in configure MCU peripherals as well as generating a C software, which is programmable and designed to perform a
code from the settings which would then be used in the IAR specific function or specific functions within a larger system [2].
Embedded Workbench. Embedded software systems primarily use operating systems or
language platforms that are adapted for real-time operation in
Keywords— embedded systems, STM32CubeMX, HAL, CMSIS, environments that require higher levels of chip capability. While
delay time, blinking rate CMSIS (Cortex Microcontroller Software Interface Standard) is
commonly used as software system for embedded applications,
I. INTRODUCTION another approach used in programming embedded systems is the
It is the objective of the experiment to: (a) demonstrate the Hardware Abstraction Layer (HAL).
use of STM32CubeMX, (b) demonstrate the Hardware Hardware Abstraction Layer is a programming approach that
Abstraction Layer (HAL) approach to programming, and (c) to interacts a microcontroller hardware at a level that is general and
explain analytically the HAL and CMSIS approaches. abstract rather than detailed through the use of a computer’s
Microcontroller (also known as MCU) programming operating system [3]. Long before this approach was introduced,
generally involves writing a set of instructions either in C MCU programmers need to know the physical interface of each
language or any other high-level programming language and microcontroller hardware before assigning instructions to it.
having these program code and data compiled into a machine- This would lend them extensive time to write a compatible
level language which is in binary form – ones and zeroes. It is a software to the specific MCU. Through the use of HAL
necessity that in writing a program on a specific language, the approach, programmers would use functions to make a hardware
programmer must have sufficient knowledge on the hardware to do something without having to know the detailed knowledge of
which the program gets uploaded into. The MCU component how the hardware is doing it. Figure 1 below shows the
that is responsible for interpreting the instructions uploaded is schematic of microcontroller programming through the aid of
the Central Processing Unit (CPU). HAL.
Fig. 1. Microcontroller programming using HAL. Image taken from [4].