Ghalebi
Newbie level 4
Salam everyone,
I am using a PIC16F84A with a 4 MHz oscillator for some purpose .. and someone fed me up with the following code in order to develop a 5 seconds delay ..
He supposed that the frequency of the oscillator is 32 KHz .. I need to understand how did he make a relation between his assumed frequency and the number 160 to get the 5 seconds delay ..
The TMR0 is set to 1:256 ..
Any kind of help is appriciated .. thanks in advance
I am using a PIC16F84A with a 4 MHz oscillator for some purpose .. and someone fed me up with the following code in order to develop a 5 seconds delay ..
Code:
;5 second delay.
DELAY5
CLRF TMR0 ;START TMR0.
LOOPB
MOVF TMR0,W ;READ TMR0 INTO W.
SUBLW .160 ;TIME - 160
BTFSS STATUS,ZEROBIT ; Check the diffrence
GOTO LOOPB ; Difference aint ZERO
RETLW 0 ;Time is 160, return.
The TMR0 is set to 1:256 ..
Any kind of help is appriciated .. thanks in advance