Question: Using ARM cortex m 4 assembly: Part one ( 0 . 3 points ) : Write a program to increment the value in register 0

Using ARM cortex m4 assembly:
Part one (0.3 points): Write a program to increment the value in register 0 by one each time
the button (PA0) is pressed (input goes from 0 to 1). Dont debounce. When testing this
code, press the button twenty times and see how many presses are counted. Dont be
surprised if the count is sometimes greater than twenty due to single presses being double
counted due to the lack of debouncing. Dont forget to initialize the button.
Part two (.8 points): Fill out the code below to do as each comment requires (youll need
more than one line of code per comment). This code will go in your __main section. For the
delay loops, you may need to experiment with the starting value from which you subtract
(see April 1 lecture).
;initialize PD12-15(output) by calling initialization subroutine
;turn off all lights to start (this can be in the initialization)
;turn on only PD12
;delay/wait ~half a second using a delay loop
;turn on only PD13(turn PD12 off)
;delay/wait ~half a second
;turn on only PD14(turn PD13 off)
;delay/wait ~half a second
;turn on only PD15(turn PD14 off)
;delay/wait ~half a second
;turn all lights off
;delay/wait ~half a second
;start the cycle again with PD12 on, then wait, etc.
Part three (1.2 points): write a program that loops through a null-terminated read-only byte
array called Numbers and displays each value on the lights. Each value in Numbers can be
between one and fifteen inclusive (with a 0x00 at the end of the array, of course, as its
null-terminated. This will be shown on the LEDs with bit 0 being represented with PD12, bit
1 with PD13, bit 2 with PD14, and bit 3 with PD15. Youll move to representing the next value
in the array after the button (PA0) is pressed and released (goes from 0/unpressed to
1/pressed and then back to 0/unpressed). After displaying the null-termination character,
start the array again from the beginning.
Example:
If the Numbers array is 1,12,9,14,0 then the PD15-12 will be off, off, off, on, respectively,
to represent 1 as binary 0001.
After the button is pressed and released, PD15-12 will be on, on, off, off to represent 12 as
binary 1100.
After the button is pressed and released again, PD15-12 will be on, off, off, on to represent
9 as binary 1001.
After the button is pressed and released again, PD15-12 will be on, on, on, off to represent
14 as binary 1110.
After the button is pressed and released again, PD15-12 will all be off to represent 0.
After the button is pressed and released again, PD15-12 will go back to 1100, as that is the
first value in the array, and the cycle will repeat.
Hints:
Use the initialization subroutines for GPIO that weve already written
Youll need to debounce the button presses by putting a delay between IDR reads
(see the April 5 lecture for more)
Since bits 3-0 of the value correspond to GPIOD ODR bits 15-12, you can use shifting
to help turn the appropriate LEDs on. Just make sure to turn off lights you wont
need.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!