Look it over. Your circuit may not respond properly if you have the wrong oscillator type selected. It can easily cause your program to seem to act strangely. In this program we use a subroutine instead of having everything in line.
Subroutines are useful for code that has to be called many times.
It saves space because only one copy in needed in the code. The routine is entered using a 'call' instruction and the 'return' instruction returns to the instruction immediately after the call instruction. Instruction Cycle Counting for Delays Time delays can be handled by using the time taken to execute instructions rather than waiting for a flag set by at timer overflow. An advantage of the PIC instruction set is that almost all instructions take the same amount of time to execute. This is the period of the oscillator divided by four.