AlGeorge
Member level 1
- Joined
- Nov 17, 2009
- Messages
- 39
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- Waihi Beach
- Activity points
- 1,606
Hi I am using the 32khz T1 internal xtal offered with some Microchip PIC types.
I figure (maybe wrong) but the internal xtal will afford me good stability at lower cost. This oscillator is div 4=8192Hz
My calculation for offset is wrong. I'm trying to achieve a 1 second interrupt, setting value T1 for the main loop. When there is a T1 interrupt, the interrupt contains the following correction code:
sub clockevent
'default timeout 8192cps/ (0.0001220703125*FFFF)=7.9998779296875
'0000/on rollover this is the default value; higher =shorter timeout 'calc=65535-8192=0xDFFF
'0xDFFF+4=0xe0ff allows for 4 cycles calling IRQ and changing offset
TMR1=0x0
TMR1H = 0xe0 '0xDF
TMR1L = 0x03 '0xFF
T1=1
end sub
However the timing over a few hours is out by about 25%. Can anyone advise where I am going wrong?
Tks vm.
Al.
I figure (maybe wrong) but the internal xtal will afford me good stability at lower cost. This oscillator is div 4=8192Hz
My calculation for offset is wrong. I'm trying to achieve a 1 second interrupt, setting value T1 for the main loop. When there is a T1 interrupt, the interrupt contains the following correction code:
sub clockevent
'default timeout 8192cps/ (0.0001220703125*FFFF)=7.9998779296875
'0000/on rollover this is the default value; higher =shorter timeout 'calc=65535-8192=0xDFFF
'0xDFFF+4=0xe0ff allows for 4 cycles calling IRQ and changing offset
TMR1=0x0
TMR1H = 0xe0 '0xDF
TMR1L = 0x03 '0xFF
T1=1
end sub
However the timing over a few hours is out by about 25%. Can anyone advise where I am going wrong?
Tks vm.
Al.