Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

2- Consider the WAIT subroutine for Tekbot discussed in class that waits for 1 sec. and returns. Rewrite the WAIT subroutine so that it waits

image text in transcribed

image text in transcribed

2- Consider the WAIT subroutine for Tekbot discussed in class that waits for 1 sec. and returns. Rewrite the WAIT subroutine so that it waits for 1 sec. using the 16-bit Timer/Counterl with the highest resolution. Assume that the system clock frequency is 16 MHz and the Timer/Counterl is operating under the CTC mode. This is done by doing the following (a) Timer/Counter is initialized to operate in the CTC mode (b) The WAIT subroutine loads the proper value into OCRIA and waits until OCF1 is set. Once OCF1 is set, it is cleared and the WAIT subroutine returns. Use the skeleton code shown below. Also, show the necessary calculations for determining value and prescale. Note that your code may not use any other GPRs besides mpr .include "m128def.inc" def mpr - r16 ORG $0000 RJMPInitialize ORG $0046 Initialize: ; End of interrupt vectors .. .Your code goes here... WAIT: .. .Your code goes here... RET [25 pts] 3- Consider the following AVR assembly code that waits for sec. using the 8-bit Timer/Counter0 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/Counter0 overflow (b) Fill in lines (3-4) with the necessary code to load the value for delay that generates an interrupt after5 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 ; Timer/Counter0 overflow interrupt vector JMP Reload counter ORG $0046 ; End of interrupt vectors Initialize: ; Enable interrupt on Timer/Counter0 overflow SEI ; Enable global interrupt ; Load the value for delay ; Set pre scalar and mode ; Set counter 4 LOOP: 2- Consider the WAIT subroutine for Tekbot discussed in class that waits for 1 sec. and returns. Rewrite the WAIT subroutine so that it waits for 1 sec. using the 16-bit Timer/Counterl with the highest resolution. Assume that the system clock frequency is 16 MHz and the Timer/Counterl is operating under the CTC mode. This is done by doing the following (a) Timer/Counter is initialized to operate in the CTC mode (b) The WAIT subroutine loads the proper value into OCRIA and waits until OCF1 is set. Once OCF1 is set, it is cleared and the WAIT subroutine returns. Use the skeleton code shown below. Also, show the necessary calculations for determining value and prescale. Note that your code may not use any other GPRs besides mpr .include "m128def.inc" def mpr - r16 ORG $0000 RJMPInitialize ORG $0046 Initialize: ; End of interrupt vectors .. .Your code goes here... WAIT: .. .Your code goes here... RET [25 pts] 3- Consider the following AVR assembly code that waits for sec. using the 8-bit Timer/Counter0 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/Counter0 overflow (b) Fill in lines (3-4) with the necessary code to load the value for delay that generates an interrupt after5 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 ; Timer/Counter0 overflow interrupt vector JMP Reload counter ORG $0046 ; End of interrupt vectors Initialize: ; Enable interrupt on Timer/Counter0 overflow SEI ; Enable global interrupt ; Load the value for delay ; Set pre scalar and mode ; Set counter 4 LOOP

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions