How do I calculate the total time consumed by a subroutine in PIC? It is given that the PIC master clock is derived from a 1MHz crystal. Here is the code given:
TEMP EQU 0x1D
DELAY MOVLW 0x80
MOVWF TEMP
NOP
DELAY1 NOP
DECFSZ TEMP,F
GOTO DELAY1
RETURN
I have calculated that there are a total of 518 instruction cycles and the total number of Q-cycles = 2072. How would I go on about if the clock is at 2MHz?
For a 8 Bit PIC:
instruction cycle Time = 4 / fOzs
1MHz means an instruction cyle of 4us. So your code will execute in 518 x 4us = 2,072ms.
2MHz means an instruction cycle of 2us. So your code will execute in 518 x 2us = 1,036ms.