Question: Assume a 1 MHz clock frequency. Explain your computations for the following questions: a ) How long is the delay introduced by a single call

Assume a 1 MHz clock frequency. Explain your computations for the following questions:
a) How long is the delay introduced by a single call of the following subroutine Delay1 in seconds when D2INIT \(=0\times 00\) and D2INIT=0x01?
b) How long is the delay introduced by a single call of the following subroutine Delay 2 in seconds?
c) Find a set of initial values for the registers dly1, dly2, dly3, and dly4 so that the Delay2 subroutine takes 2.0 seconds with a \(1\%\) error margin.
2)
Write the Assembly code to initialize Port B bits 3 and 6 to outputs and bit 5 to input. Then, write the code to read button 5 from port \( B \) and display it at bit 6 and its complement at bit 3 of the same port.
3)
What is the largest number of nested subroutine calls that can be implemented on an ATmega32 microcontroller without any external memory? How about with full external memory?
4) Consider the following code to answer the following questions. Assume that each call of long_delay takes 100 milliseconds, and all other code takes no time at all. LOOP:
NO_PRESS:
a) Describe the situation that results in the shortest delay between any button on PinD being pressed and the LEDs turning off. Write down a timeline to show which code the processor executes and when. (For example: \(\mathrm{t1}\)- t2: display complement of bit0; t2- t3: long_delay; t3- t4: display complement of bit1; ........)
b) Describe the situation that results in the longest delay between any button on PinD being pressed and the LEDs turning off. Write down a timeline to show which code the processor executes and when.
c) Describe the situation that results in the longest time that button can be pressed (and then released) without the LEDs turning off. Write down a timeline to show which code the processor executes and when.
d) Modify the code to run button readings and LED output in a more concurrent way by using FSM-based tasks.
Assume a 1 MHz clock frequency. Explain your

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 Programming Questions!