Quote Originally Posted by PicLearner View Post
Let's say I use interrupt for 1 second using 16bit timer. 8mhz / 4 cycles / 16bit timer 65536 = 0.000030517578125 multiply by 256 prescaler = 0.0078125. 1 second / 0.0078125 = 128. As I understand it should interrupt the software 128 times per second. How do I figure it out if it will not conflict during ADC, CCP, EEPROM, CCP sampling, writing and erasing? I know I can disable interrupt routine during any of these sampling but it'll mess up the time. Is it even possible to do that without external RTC?
8Mhz / 4 = 2Mhz...
Clocking a 16 bit timer off the instruction clock @ 2Mhz = 2Mhz / 65536 = 30.517578125 interrupts per second (have to take the 1/x of the result, that's the part you forgot).
Set up the interrupt routine to count to 30, then take a sample. Yes, you'll be 16.69ms off for each second, unless you reload that particular timer at each interrupt with a correction factor to make it exactly one second. Look up the phrase PIC Multi-Calc.
If you clock an 8 bit timer off the instruction clock @ 2Mhz, 2Mhz / 256 = 7812.5 interrupts per second. Set up that interrupt routine to count to 7812, then take a sample. With the 8 bit timer, you'll only be 65us off in each second.