PIC Microcontrollers: Chapter 5: Branch, Call, and Time Delay Loop
PIC Microcontrollers: Chapter 5: Branch, Call, and Time Delay Loop
PIC Microcontrollers: Chapter 5: Branch, Call, and Time Delay Loop
• Solution:
▫ (a) 4/4 = 1 MHz; instruction cycle is 1/1 MHz= 1 μs (microsecond)
▫ (b) 16 MHz/4 = 4 MHz; instruction cycle = 1/4 MHz= 0.25 μs = 250 ns
▫ (c) 20 MHz/4 = 5 MHz; instruction cycle= 115 MHz= 0.2 μs = 200 ns
▫ The above instructions at the beginning and end of the AGAIN loop add 5 x 200
x 1 μs = 1000 μs to the time delay.
▫ We should also subtract 200 μs for the times BNZ HERE falls through.
▫ As a result we have 250000 + 1000 - 200 = 250800 μs = 250.8 milliseconds for
the total time delay associated with the above DELAY subroutine.
▫ Notice that in the case of a nested loop, as in all other time delay loops, the time
is approximate because we have ignored the first few instructions and the last
instruction, RETURN, in the subroutine.
Gaby Abou Haidar M.S. Fall 2017 - 2018
• Example: Find the time delay for the following subroutine, assuming a
crystal frequency of 4 MHz. Discuss the disadvantage of this example