Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Computer Organization and Assembly Language Programming [25 pts] 3- Consider the following AVR assembly code that waits for 1 sec. using the 8-bit Timer/Counter with
Computer Organization and Assembly Language Programming
[25 pts] 3- Consider the following AVR assembly code that waits for 1 sec. using the 8-bit Timer/Counter with the system clock frequency of 16 MHz operating under Normal mode. Write and explain the instructions in lines (1-10) necessary to make this code work properly. More specifically, (a) Fill in lines (1-2) with the necessary code to enable the interrupt on Timer/Counter) overflow. (b) Fill in lines (3-4) with the necessary code to load the value for delay that generates an interrupt after 5 ms. (c) Fill in lines (5-6) with the necessary code to set the prescalar value and the mode of operation. (d) Fill in line (7) with the necessary code to set counter. (e) Fill in lines (8-9) with the necessary code to reload the value for delay. (f) Fill in line (10) with the necessary code to decrement counter. .include "m128def.inc" .def mpr = r16 .def counter = r17 .ORG $0000 RJMP Initialize .ORG $0020 Reload_counter .ORG $0046 ; Timer/Countero overflow interrupt vector ; End of interrupt vectors Initialize: SEI ; Enable interrupt on Timer/Counter 0 overflow ; Enable global interrupt Load the value for delay (3) ; Set prescalar and mode Set counter LOOP: counter, o BRNE LOOP ; Repeat until interrupted Reload_counter: PUSH mpr ; Save mpr (8) ; Load the value for delay (9) i (10) ; Decrement counter ; Restore mpr POP RETI mpr [25 pts] 3- Consider the following AVR assembly code that waits for 1 sec. using the 8-bit Timer/Counter with the system clock frequency of 16 MHz operating under Normal mode. Write and explain the instructions in lines (1-10) necessary to make this code work properly. More specifically, (a) Fill in lines (1-2) with the necessary code to enable the interrupt on Timer/Counter) overflow. (b) Fill in lines (3-4) with the necessary code to load the value for delay that generates an interrupt after 5 ms. (c) Fill in lines (5-6) with the necessary code to set the prescalar value and the mode of operation. (d) Fill in line (7) with the necessary code to set counter. (e) Fill in lines (8-9) with the necessary code to reload the value for delay. (f) Fill in line (10) with the necessary code to decrement counter. .include "m128def.inc" .def mpr = r16 .def counter = r17 .ORG $0000 RJMP Initialize .ORG $0020 Reload_counter .ORG $0046 ; Timer/Countero overflow interrupt vector ; End of interrupt vectors Initialize: SEI ; Enable interrupt on Timer/Counter 0 overflow ; Enable global interrupt Load the value for delay (3) ; Set prescalar and mode Set counter LOOP: counter, o BRNE LOOP ; Repeat until interrupted Reload_counter: PUSH mpr ; Save mpr (8) ; Load the value for delay (9) i (10) ; Decrement counter ; Restore mpr POP RETI mpr
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started