I am trying to make a 16f684 clock program. I plan on using batteries.
If i use the int rc osc 31k hz clock, will it drift according to temperature and voltage. I read the datasheet and it said the external rc clock would drift. I didnt see any info regarding internal rc drift?
I suppose if the 31k osc drifts around too much ill have to use the 125k osc.
I'm not familiar with that particular pic but, assuming it's the same as most other pics, to do a clock type program. Run the processor at 4MHz using the internal oscillator and use a 32.768kHz (8000h) Crystal as the external clock for timer 1. You can then use the special events trigger of ccp1 to generate a 1Hz interrupt.
If you use a RC oscillator to generate interrupts then you will have a very inaccurate clock.
To setup Timer1 and CCP1, do:
Code:
movlw B'00001111'; enable timer1
movwf T1CON; with external clock
movlw low(8000h-1); Lets interupt every second
movwf CCPR1L; using the special event trigger on timer 1
movlw high(8000h-1)
movwf CCPR1H
movlw B'00001011'; enable special event trigger on CCP1
movwf CCP1CON;
bsf STATUS,RP0
bsf PIE1,CCP1IE; enable CCP1 interrupt
bcf STATUS,RP0
movlw 0C0h
movwf INTCON; enable Peripheral interrupts
And your interrupt would look something like:
Code:
interrupt movwf int_work
swapf STATUS,W
movwf int_status; status is nibble swaped
bcf STATUS,RP0
bcf PIR1,CCP1IF; reset special event trigger interupt
incf Seconds; increment seconds as a second has passed
swapf int_status,W
movwf STATUS
swapf int_work,F; swap to file
swapf int_work,W; swap to work
retfie
I am trying to make a 16f684 clock program. I plan on using batteries.
If i use the int rc osc 31k hz clock, will it drift according to temperature and voltage. I read the datasheet and it said the external rc clock would drift. I didnt see any info regarding internal rc drift?
I suppose if the 31k osc drifts around too much ill have to use the 125k osc.