Professional Documents
Culture Documents
MPSI Quiz1b Solution
MPSI Quiz1b Solution
MPSI Quiz1b Solution
Q2 . Find the number of clock cycles needed, to execute the program given above. Also
find the duration when running on 2 MHz oscillator
The loop is executed 6 (six) times since the loop variable is loaded with value 6 and it
decrements each iteration until it reaches zero. The loop BRNE breaks when R16 = 0.
1
For 𝑓𝑜𝑠𝑐 = 2 𝑀𝐻𝑧, 𝑇𝑜𝑠𝑐 = 𝑓 = 0.5 μs = 500 ns
𝑜𝑠𝑐
• Increment R20 NNN times using a loop (where NNN is your reg#)
• Write incremented value to PORTD in each loop iteration
• PORTD must be declared output, in the start
• It is suggested to use BRNE conditional branching instruction