Can Someone please explain me how to count a 1 ms delay for pic with 8 Mhz oscillator ? I mean what value i should put into TMRx register to acquire such a delay - and what prescaller (if needed ) should be used.
reloadT1Hi equ 255
reloadT1Lo equ 6 ; trimming
count equ 0x20
org 0
goto setup
org 4
retfie
; 8 megs-->> one tick = 0.125 uSec
; prescale by 8 -->> 1 uSec / tick
setup movlw 00110000b;leave bit 0 = 0
movwf t1con
clrf count
; must preset High and Low
; must check interrupt flag(no need for interrupt)
; just the flag
loop
use bcf status,rp0 ; 1 make sure to be in the right bank
bcf pir1,tmr1if ; 1
movlw reloadT1Hi ; 1
movwf tmr1h ; 1
movlw reloadT1Lo ; 1
movwf tmr1l ; 1
bsf t1con,0 ; 1 from now on progr steps are not delays
testt1 btfss pir1,tmr1if
goto testt1
; timed out 1 usec for 8 ticks
incf count,f
goto loop
end
Just cooked this one
Note: You would need a Xtal to run at 8 megs on a 16F676
for any uc set the prescale register than set the register to which it should matces(like match register) and see the clock parameter that which clock the timer is using.