ReportTemplate PracticalTask or Project
ReportTemplate PracticalTask or Project
By
ii
ABSTRACT
iii
TABLE OF CONTENTS
LIST OF TABLES......................................................................................................vii
LIST OF FIGURES....................................................................................................viii
LIST OF ABBREVIATIONS......................................................................................ix
CHAPTER 1 INTRODUCTION...................................................................................1
1.1 OBJECTIVE.....................................................................................1
CHAPTER 2 LITERATURE REVIEW………………………………………………2
CHAPTER 3 METHODOLOGY……………………………………………………..4
CHAPTER 4 RESULTS AND DISCUSSION………………………………………11
CHAPTER 5 CONCLUSION……………………………………………………….19
REFERENCES..............................................................................................................2
APPENDICES...............................................................................................................3
iv
LIST OF TABLES
v
LIST OF FIGURES
Figure 1..........................................................................................................................1
Figure 2..........................................................................................................................1
Figure 3..........................................................................................................................1
Figure 4..........................................................................................................................1
vi
LIST OF ABBREVIATIONS
EQU Equivalent
vii
CHAPTER 1
INTRODUCTION
1.1 OBJECTIVE
2
The programming language employed is assembly language code, which is
written using Keil uVision4, an Integrated Development Environment (IDE) that
includes a text editor, compiler, and the ability to convert source files to the .bin
format. To make modifications to the STM32F411RE project model in Keil
uVision4, a similar model, the STM32F401RE, is selected from the menu. It is
important to save the file before making any changes, compiling, and converting it to
the .bin format.
3
CHAPTER 3
METHODOLOGY
The NUCLEO-F411RE board has been selected as the hardware for the task,
while Keil uVision4 has been chosen as the software. The "startup stm32f401xx.s"
file serves as the primary file for editing, compiling, and converting the model.
3.1 TASK 1A
The chosen extra components are male-to-female wires and LEDs. A system
of binary codes consisting of 1's and 0's is utilized to indicate whether the LEDs are
in an "ON" or "OFF" state. It's important to have knowledge about the different LED
connections, such as active-high and active-low, in order to communicate effectively
between the hardware and software. An active-high configuration means that when
the bit is 1, the LED will light up, while an active-low setup will illuminate the LED
when the bit is 0.
4
3.1.1 TASK 1A (a)
To create the code, the output pins selected were GPIO and PA5. To transfer
the code to the NUCLEO-F411RE board, a mini-USB B port was used along with a
USB Type-A to Mini-B cable to receive the data. LED 1 is indicated by a green light.
To illuminate LED 1, bit 1 is assigned to PA5 through the use of GPIOA ODR. After
receiving the pre-developed instruction via a .bin file, the hardware executes the code
and the resulting data is obtained.
5
resulting data is obtained.
3.1.5 TASK 1A (e)
During the code-writing process, the output pins chosen were GPIOC and
PC6. To transfer the code to the NUCLEO-F411RE board, a mini-USB B port was
utilized along with a USB Type-A to Mini-B cable to receive the data. LED 3, which
is yellow in color, is connected in an active-high configuration. To illuminate LED 3,
bit 1 is assigned to PC6 through the use of GPIOC ODR. Following the hardware's
receipt of the pre-existing instruction via a .bin file, the code is executed and the
resulting data is obtained
3.1.6 TASK 1A (f)
The GPIOA and PA5 pins were chosen as the output when the code was being
written. A mini-USB B connector was utilised to accept the data from a USB Type-A
to Mini-B cable in order to send the code to the NUCLEO-F411RE board. When the
delay function is chosen, LED 1 (green) starts flashing. Bit 0 is reset, bit 1 is set, and
bit 1 is assigned to BSRR in order to turn off the LED 1 (green). Bits 1 and 0 are in
the reset and set positions, respectively, to restart LED 1. In exchange, the hardware
was given a previously generated instruction through a.bin file, and outcomes were
obtained.
6
that was previously developed in a .bin file and the results are obtained.
3.2 TASK 1B
Task 1B involves the use of additional hardware, including LEDs, switches,
and male-to-female jumper wire. As with Task 1, LED1, LED2, and LED3 were
utilized. To successfully carry out this task, one needs to have basic knowledge of
setting up switches with pull-up resistors, which is illustrated in Figure 4.
For this task, a switch (SW1) and two LEDs (LED1 and LED2) were utilized as
additional hardware. LED1 is connected to PB0 and LED2 is connected to PB1 using
an active-low setup. On the other hand, SW1 is connected in a pull-up resistor setup,
as depicted in Figure 4. The code was written using the GPIOB and GPIOC, where
PB1 is configured as an output and PC0 as an input. To upload the code onto the
NUCLEO-F411RE board, a mini-USB B port was employed with the use of a USB
Type-A to Mini-B cable.
• When the switch (SW1) is pressed, the input value becomes LOW and the bit
1 (HIGH) is assigned to PB0 using ODR, which causes LED 1 to light up and
LED2 to turn off.
• When switch (SW1) is pulled, the input is HIGH and PB0 receives bit 0
(LOW) using ODR resulting in LED1 turning off and LED2 lights up.
The hardware was given a pre-developed instruction via a .bin file, and the outcome
was obtained as a result.
7
3.2.2 TASK 1B(b)
To accomplish this task, two switches (SW1 and SW2) and three LEDs
(LED1, LED2, and LED3) were utilized. LED1 is connected to PA0, LED2 to PA5 in
an active-low configuration, and LED3 to PA1 in an active-high setup. SW1 is
connected to PC0 and SW2 to PB0 with pull-up resistors as shown in Figure 4.
GPIOA, GPIOB, and GPIOC are used in the code, with PA0, PA5, and PA1 set as
output, and PC0 and PB0 as input. A mini-USB B port was utilized to transfer the
code to the NUCLEO-F411RE board via a USB Type-A to Mini-B cable.
If both switches SW1 and SW2 are activated, the input at C is [11]. This leads
to an output of 0 being transmitted to PA0 (LED1) and PA1 (LED3), while an
input of 1 is transferred to PA5 (LED2).
If SW1 is activated while SW2 is pushed, the input at C becomes [01], which
leads to an output of 1 being transferred to PA0.
When both switch SW1 and SW2 are pushed, the input at C is [00]. Output of
0 is transferred to PA5 (LED2).
The hardware obtained a pre-developed instruction via a .bin file, and the
outcomes were obtained in return.
3.3 TASK 1C
An LCD is also used in this operation, with Ports B and C being utilised, in
addition to switches and Lights. Connect all of the LCD's high-order and low-order
buses using GPIO ODR in 8-bit mode to display a message on the LCD. The third
command is used to check for the busy flag after the command set function has been
updated three times. The LCD's entry command is set up as 0000000110, where 1
denotes increases and 0 denotes decreases. Moreover, the message can flash or shift
to the right by using bit 1.
8
Figure 5: Pin connection of LCD.
Lastly, using the vector table, set two lines of characters for display on the
LCD. The first line of characters reads "<Programming My>" while the second line
reads "<<Nucleo Board>>".
9
3.4 TASK 1D
Additional hardware used in this task is SW1 switch. Set up GPIO Port A pin 0 as
input (connected to SW1) . The first four instructions enable the clock for GPIOA by
setting bit 0 of the RCC_AHB1ENR register to 1. This is done to enable access to the
GPIOA registers. The next two instructions clear the moder register and pupdr
register for GPIOA. This is done to configure GPIOA pin 0 as an input with no pull-
up or pull-down resistor.The program enters an infinite loop labelled "loop". Within
the loop, the program reads the state of the switch connected to GPIOA pin 0.
The instruction LDR R0, [R1, #0x10] loads the value of the IDR (input data register)
of GPIOA into register R0. The offset of 0x10 is used because the IDR register is
located at an offset of 0x10 from the base address of GPIOA. The instruction ANDS
R0, R0, #1 performs a bitwise AND operation between R0 and the value 1. This is
done to check the value of the first bit of R0, which corresponds to the state of the
switch connected to GPIOA pin 0. The instruction BEQ switch_released branches to
the label "switch_released" if the result of the ANDS operation is zero. This means
that the switch is not pressed.If the switch is pressed, the program sets the value of R0
to 1 and branches to the label "display_logic". The label "switch_released" is
executed if the switch is not pressed. It sets the value of R0 to 0. The label
"display_logic" is where the logic value of the switch (0 or 1) is displayed. The code
to display the value is shown after the label.Finally, the program branches back to the
beginning of the loop, where it repeats indefinitely.
10
CHAPTER 4
RESULTS AND DISCUSSION
4.1 Task 1A
The green LED labeled LED1 on the NUCLEO-F411RE board lights up when
the board is powered on and code is running, as anticipated. This LED turns on
because pin PA5 receives a signal of 1 through BSSR.
11
4.1.3 Task 1A(c)
The red LED, LED2, on the board lights up when the board is powered on and
the code is executed, as anticipated. LED2 is configured as an active-low, which
means it illuminates when pin PB6 receives a signal of 0 through BSSR.
As expected, the yellow LED labeled LED3 lights up when the board is
powered on and the code starts running. LED3 is set up as an active-low, which
means it illuminates when pin PC6 receives a signal of 1 through BSRR.
As expexted, when the board is powered on and the code is executed, the yellow
LED named LED3 lights up. LED3 is configured as active-high and turns on because pin C6
receives a signal of 1 through ODR.
12
4.1.6 Task 1A(f)
The desired outcome was achieved, where the green LED blinks when the
board is powered on and the code is executed. LED1 is configured as active-high
and lights up because pin A5 receives a signal of 1 through BSRR.
The anticipated result was achieved as the red LED named LED2 blinks when
the board is powered on and the code is executed. LED2 is configured as active-high
and lights up because pin B6 receives a signal of 1 through BSRR.
13
Expected result Actual result
• https://youtu.be/3bjUDyHdebY
Blink LED 3/YELLOW LED
using suitable delay LED 3/Yellow LED blinks
The desired outcome was achieved, where the yellow LED named LED3
blinks when the board is powered on and the code is executed. LED3 is set up as
active-high and lights up because pin C6 receives a signal of 1 through ODR.
As anticipated, each LED1, LED2, and LED3 illuminates alternately. This can
be accomplished by implementing a delay function and looping through the same
code repeatedly. Similar to the previous task, the BSRR and ODR were used to light
up each LED.
4.2 Task 1B
14
Step No Action Expected Result
Actual Result Recorded Result
15
1 SW1 and SW2 LED1,LED2 and LED1,LED2 and https://youtu.be/uh2IghqXz_Y
are released LED 3 OFF LED 3 OFF
2 LED3 LED3
SW1 pushed
illuminates, illuminates,
downward, SW2
LED1 and LED2 LED1 and LED2
released
OFF OFF
3 SW1 released, LED1 LED1
SW2 pushed illuminate, illuminate,
downward LED2 and LED3 LED2 and LED3
OFF OFF
4 SW1 and SW2 are LED2 LED2
pushed illuminates, illuminates,
downward LED1 and LED3 LED1 and LED3
OFF OFF
Table 11: Result for Task 1B(b)
SW1 and SW2 were configured to produce a HIGH input signal when they are
not pressed and a LOW input signal when they are pressed. SW1's input pin is
connected to PC0, while SW2's input pin is linked to PB0. When both switches are
not pressed, the input pin becomes [11], which switches off all LEDs by sending 0 to
PA0 and PA1 for LED1 and LED3, respectively, and 1 to PA5 for LED2. The input
at pin [10] is then [10] when SW1 is pressed, while SW2 is not pressed. As a result,
only LED3 will light up when PA1 receives a signal of 1. Additionally, when SW1 is
not pressed, while SW2 is pressed, the input at pin [01] is set, causing LED1 to be the
only one to turn on by providing a signal of 1 to PA0. When both switches are
pressed, the input at the pin becomes [00], causing LED2 to be the only one to
illuminate. This is achieved by setting LED2's PA5 output to zero. To keep LED1 and
LED3 in the off state, PA0 and PA1 must have a signal of 0.
4.3 Task 1C
16
Static message displayed on LCD https://youtube.com/shorts/HCQNlwHVPu8?
as per below: feature=share
ROW 1: <Programming My> • Static message displayed on the LCD
ROW 2: << Nucleo Board>>
The LCD displayed two lines of text, with "<Programming My>" shown on
the first row, and "<<Nucleo Board>>" on the second row. The first and second rows
of the vector table were used to display these messages. To move from the first row to
the second, the cursor was positioned to the second line.
4.4 Task 1D
17
1 Push SW1 Static message https://youtube.com/
downward displayed on LCD shorts/JSm2jRTYJQo
as per below:
ROW1:Logic 0: 0 V
ROW 2: SW1 Pressed
Static message
displayed on LCD
as per below:
ROW1:Logic 0: 0 V
ROW 2: SW1 Pressed
When the SW1 button is pressed, two lines of text were displayed on the LCD: "
Logic 0: 0 V " in the first row and " SW1 Pressed " in the second. The switches SW1
was configured to provide a LOW input when they are released and a HIGH input when
they are clicked. When the SW1 button is released, two lines of text were displayed on
the LCD: " Logic 1: 3.3 V " in the first row and " SW1 Released " in the second..
CHAPTER 5
CONCLUSION
By the end of practical task #1, all objectives had been achieved. The first
objective was to learn how to utilise the NUCLEO-F411RE Board to switch output
18
devices on and off by assigning bit 1 or bit 0 to the initialised output pins. The second
objective was to employ switches to adjust the brightness of the LEDs using the
NUCLEO-F411RE Board. This was accomplished by transmitting high or low input
through bit 1 or 0 when the switch was pressed or released. To achieve the remaining
two objectives of displaying messages on the LCD, change the display when the
switch is pressed or released, addresses were established, the LCD was initialised,
and the vector table was utilised. Ultimately, all goals were successfully
accomplished. Throughout the project, two critical skills were gained: learning how
to write code in a new language on a new platform, specifically assembly language in
Keil's case, and acquiring proficiency in using the NUCLEO-F411RE Board. These
skills will be useful in future careers, particularly when working with processors.
19
REFERENCES
STMicroelectronics NV. (2021) NUCLEO-XXXXCX NUCLEO-XXXXRX NUCLEO-
XXXXRX-P Data Brief, STM32 Nucleo-64 Boards. STMicroelectronics. Retrieved from
https://docs.rs-online.com/2f7f/0900766b81440071.pdf
Digi-Key Electronics. (2022) STM32® 32-bit MCU Family, Leading Supplier of ARM®
Cortex®-M Microcontrollers, Development Boards. Retrieved from
https://www.digikey.com/en/product-highlight/s/stmicroelectronics/stm32-kits
Anas Ejaz. (2020) Pull-Up and Pull-Down Resistor, Electronics Tutorial. Retrieved from
https://www.circuits-diy.com/pull-up-and-pull-down-resistor-electronics-tutorial/
20
APPENDICES
Link to the code:
1. Task 1A
a. https://drive.google.com/file/d/1DioMNsQ4H41KZthv3k5WJidkJFhaErf1/
view?usp=share_link
2. Task 1B(a)
a. https://drive.google.com/file/d/1iFLtPBg2ihSLSJysjiE9JP5dWobmLgib/view?
usp=share_link
3. Task 1B(b)
a. https://drive.google.com/file/d/1d_2FppPRJH9B5jX-iuEqWtgg6ppBzKhH/view?
usp=share_link
4. Task 1C
a.https://drive.google.com/file/d/1tEwhFBmzcmp7lOu2t0G2RM4A289HK612/view?
usp=share_link
5. Task 1D
a. https://drive.google.com/file/d/1OTS40t3V0NCiGPF8ATZ91X7jO-F_SFlD/view?
usp=share_link
21