krytenrobot
New Member
i am trying to create a 1sec delay using the timer0 in the 12f629, by pre loading it with 131 and when it counts up it will overflow to zero so i can test the status z, after 125 counts that will be 4msec.
(131+125= 256 ,overflow to zero)
i have set the prescaler to 1/32 tmr0.
internal osc 4mhz
is this possible with this pic or not, i am used to using the 16f84
here is my asm file>>
;blink12F629.asm
;This program will blink a LED at 1hz connected to pin 7
;17-8-2010 D nelson
list p=12F629
include "p12f629.inc"
__CONFIG _CP_OFF & _MCLRE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _BODEN_OFF & _CPD_OFF &_PWRTE_OFF
errorlevel -302 ;ignore Bank warnings
;**********************************************************************
;Equates
;*************************************************************************
fileA equ 20h
fileB equ 21h
fileC equ 22h
pin7 equ 0
pin6 equ 1
pin5 equ 2
pin4 equ 3
pin3 equ 4
pin2 equ 5
Start org 0x0
nop
nop
nop
nop
nop
Setup bsf STATUS,RP0 ; swap banks
movlw b'10000100' ;prescaler tmro 1/32 pullups disabled
movwf OPTION_REG
movlw b'00101110' ;set i/o pins gp4 and gp0 as outputs
movwf TRISIO
movlw b'00000111' ;turn off comparitor
movwf CMCON
call 0x3ff ; calibrate oscillator
movwf OSCCAL
bcf STATUS,RP0
clrf GPIO
movlw d'0'
movwf INTCON ; disable all interupts
goto Main
Del1 movlw d'250' ;preload with 250// 4msec x 250=1sec
movwf fileA
Del2
movlw d'131';preload with 131
movwf TMR0
Wait movf TMR0,1
btfss STATUS,Z; has tmr0 overflowed to zero/ 32usec x 125=4msec?
goto Wait ; no do it again
Dela decfsz fileA,1 ; yes so reduce counter by 1
goto Del2
return
Main
bsf GPIO,pin7
call Del1
bcf GPIO,pin7
call Del1
goto Main
org 3ff
retlw 0x60
END
(131+125= 256 ,overflow to zero)
i have set the prescaler to 1/32 tmr0.
internal osc 4mhz
is this possible with this pic or not, i am used to using the 16f84
here is my asm file>>
;blink12F629.asm
;This program will blink a LED at 1hz connected to pin 7
;17-8-2010 D nelson
list p=12F629
include "p12f629.inc"
__CONFIG _CP_OFF & _MCLRE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _BODEN_OFF & _CPD_OFF &_PWRTE_OFF
errorlevel -302 ;ignore Bank warnings
;**********************************************************************
;Equates
;*************************************************************************
fileA equ 20h
fileB equ 21h
fileC equ 22h
pin7 equ 0
pin6 equ 1
pin5 equ 2
pin4 equ 3
pin3 equ 4
pin2 equ 5
Start org 0x0
nop
nop
nop
nop
nop
Setup bsf STATUS,RP0 ; swap banks
movlw b'10000100' ;prescaler tmro 1/32 pullups disabled
movwf OPTION_REG
movlw b'00101110' ;set i/o pins gp4 and gp0 as outputs
movwf TRISIO
movlw b'00000111' ;turn off comparitor
movwf CMCON
call 0x3ff ; calibrate oscillator
movwf OSCCAL
bcf STATUS,RP0
clrf GPIO
movlw d'0'
movwf INTCON ; disable all interupts
goto Main
Del1 movlw d'250' ;preload with 250// 4msec x 250=1sec
movwf fileA
Del2
movlw d'131';preload with 131
movwf TMR0
Wait movf TMR0,1
btfss STATUS,Z; has tmr0 overflowed to zero/ 32usec x 125=4msec?
goto Wait ; no do it again
Dela decfsz fileA,1 ; yes so reduce counter by 1
goto Del2
return
Main
bsf GPIO,pin7
call Del1
bcf GPIO,pin7
call Del1
goto Main
org 3ff
retlw 0x60
END