Actually, I'm in a similar boat:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Im hoping that my previous reply will give you some help in determining a good stable clock source. You do not need to use the prescaler using the internal xtal, just add the TMR1 values **note the higher TMR1 val, the shorter the interrupt timeout.** For example, using the default TMR1 value of 0000 interrupts will occur every 8 seconds
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
We want to measure from 200 RPM up to 6000RPM.
We have a PIC16f628 and a hall sensor on CCP1 pin.
Of course we want fewer CCP interrupts & noise immunity
How can we determine the best values for Timer1 prescaler and for the CCP1CON.
Thank you
Actually, I'm in a similar boat:
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.
Im hoping that my previous reply will give you some help in determining a good stable clock source. You do not need to use the prescaler using the internal xtal, just add the TMR1 values **note the higher TMR1 val, the shorter the interrupt timeout.** For example, using the default TMR1 value of 0000 interrupts will occur every 8 seconds