trennonix
New Member
Hello again,
I'm having some trouble writing timing code for the 12F675
I was trying to get an exact one sec delay to be then used for minutes and hours delays
I'm basically making a timer.
For one minute, my program gave me 50 sec, 10 sec short
So i used a code generator from the web, same thing, thus i'm assuming that my code is clean.
Thanks
btw how do i get the code to have a clean look on the web, all TABS are gone when i posted this so might be a bit annoying to read, Sorry
I'm having some trouble writing timing code for the 12F675
I was trying to get an exact one sec delay to be then used for minutes and hours delays
I'm basically making a timer.
For one minute, my program gave me 50 sec, 10 sec short
So i used a code generator from the web, same thing, thus i'm assuming that my code is clean.
Off the WEB
DELAY_ONE_SECOND
;999990 cycles
MOVLW b'00000010'
XORWF GPIO, 1
movlw 0x07
movwf COUNTER1
movlw 0x2F
movwf COUNTER2
movlw 0x03
movwf COUNTER3
DELAY_ONE_SECOND_0
decfsz COUNTER1, f
goto $+2
decfsz COUNTER2, f
goto $+2
decfsz COUNTER3, f
goto DELAY_ONE_SECOND_0
;6 cycles
goto $+1
goto $+1
;4 cycles (including call)
return
However, i've set the micro to use the internal oscillator, and i read somewhere that this needs to be calibrated (no idea whatsoever about that OSCAL??? ); could this be my problem? and how do i solve it?My code
DELAY_ONE_SECOND1:
MOVLW b'00000010'
XORWF GPIO, 1
MOVLW D'100'
MOVWF COUNTER3
LABEL3
MOVLW D'13'
MOVWF COUNTER1
LABEL1
MOVLW D'255'
MOVWF COUNTER2
LABEL2
DECFSZ COUNTER2, 1
GOTO LABEL2
DECFSZ COUNTER1, 1
GOTO LABEL1
DECFSZ COUNTER3, 1
GOTO LABEL3
RETURN
Thanks
btw how do i get the code to have a clean look on the web, all TABS are gone when i posted this so might be a bit annoying to read, Sorry
Last edited: