skyrock
New Member
i've worked a test code using TMR0 to produce a 1sec interval but when I switched different power (9v ~ 15v) supplied to 7805 gives different results.. I notice there's no resistor connected from 7805 to the IC, does that gives problem?
Can anyone explain a little how internal oscillator/TMR0 works?
///////// My Code ///////////////////////////
ORG 0x00
goto MAIN
ORG 0x04
goto ISR
MAIN
bsf STATUS, RP0 ; Sets up PORTB for OUTPUT to LED
clrf TRISB
movlw b'10000101' ; PRESCALLER to 1:64
movwf OPTION_REG
bcf STATUS, RP0
clrf PORTB
bsf INTCON, T0IE ; sets up interrupt... I guess
movlw .178 ;(256-178)=78*64us = 4.992ms tick
movwf TMR0
bsf INTCON,GIE
clrf CNT ; CNT is defined in cblock, just omitted
LOOP ; here to save space
goto LOOP
ISR
movlw .178
movwf TMR0
bcf INTCON, T0IF
incf CNT, F
movlw .200 ;200 * 4.992ms = 1sec.
subwf CNT,W
btfss STATUS, Z
retfie
comf PORTB, f
clrf CNT
retfie
END
p.s. i've used the main board from Nigel's tutorial.. thanks Nigel, nice job.
Regards,
SKY
Can anyone explain a little how internal oscillator/TMR0 works?
///////// My Code ///////////////////////////
ORG 0x00
goto MAIN
ORG 0x04
goto ISR
MAIN
bsf STATUS, RP0 ; Sets up PORTB for OUTPUT to LED
clrf TRISB
movlw b'10000101' ; PRESCALLER to 1:64
movwf OPTION_REG
bcf STATUS, RP0
clrf PORTB
bsf INTCON, T0IE ; sets up interrupt... I guess
movlw .178 ;(256-178)=78*64us = 4.992ms tick
movwf TMR0
bsf INTCON,GIE
clrf CNT ; CNT is defined in cblock, just omitted
LOOP ; here to save space
goto LOOP
ISR
movlw .178
movwf TMR0
bcf INTCON, T0IF
incf CNT, F
movlw .200 ;200 * 4.992ms = 1sec.
subwf CNT,W
btfss STATUS, Z
retfie
comf PORTB, f
clrf CNT
retfie
END
p.s. i've used the main board from Nigel's tutorial.. thanks Nigel, nice job.
Regards,
SKY