Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 2 (35 Points) - The program given below implements a general purpose nes

ID: 3348707 • Letter: P

Question

Problem 2 (35 Points) - The program given below implements a general purpose nested delay loop. Assume that the clock frequency of the Arduin microcontroliler ft-20 MH and that the number of clock cycles for each instruction is given. Assume also that the values of RepetitionsI and Repetitions 2 can be any integer number between 1 and 32767 int Count1-Repetitions1 While (Count1>-0) /15 clock Cycles /5 clock Cycles /15 clock Cycles /5 clock Cycles /5 clock Cycles fint Count2-Repetitions2; while (Countz»-?) int A 0; count2-count2-1; Count1- Count1-1; /5 clock Cycles For the following questions ignore any overhead and write all your calculations on the s provided pace i. (2 points) Which is the clock period? clock f 2010 5 points ) Which is the Minimum delay that can be implemented by the general purpose delay loop? i. ( u) i. (5 points) Which is the maximum delay that can be implemented by the general purpose delay? 2. 2

Explanation / Answer

Answer :- i) The clock period is = 1/20 us = 0.05 us.

Answer :- ii) The minimum count value is 1. So each while codition will be executed thrice (once for count = 1 and then for count = 0), at count = -1 loop terminates but 15 clock cycle is taken to check. Thus we get a total of 170 clock cycles. Hence minimum delay = 170 x 0.05 us = 8.5 us.

Answer :- iii) The maximum count value = 32767. Inner while loop takes (25 x (count2 + 1)) + 15 . Thus for count2 = 32767, inner loop takes (25 x 32768) + 15 clock cycles = 819215 cs.

Outer while loop takes ((819215 + 25) x (count1 + 1)) + 15 + 5 (initial) . Thus for count1 = 32767, outer loop takes (819240 x 32768) + 15 + 5 clock cycles = 26844856340 cs.

Total Delay = 0.05 x 26844856340 x 10-6 s = 1342.24 s.

Answer :- iv) If count2 = 10000 then inner while cs = (25 x 10001) + 15 = 250040 cs.

So we can write, (250065 x (count1 + 1) ) + 20 = (107/0.05) = 2 x 108 . On solving we get count1 = 799.

Answer :- v) The value can be calculated by keeping count1 = count2 = 256 in 3rd sub-part of this question. Byte is of 8-bit, so maimum count value can be 256. Thus we get maximum delay = 87 ms.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote