The xtal frequency is divided by 4 initially, and then TMR0 interrupts on= =20 overflow from 255->0, meaning another divide by 256. So minimum divide i= n=20 this situation is 1024. If you need 1 Hz resolution, your xtal freq shou= ld=20 be divisible by that, assuming no pre-scaler. If you need an interrupt e= very=20 1/100-th of 1Hz, now you need a xtal that divides by 102400. However, you *can* change TMR0 manually to make the overflow divisible by= =20 something else, but that just adds another complication. Writing to TMR0= =20 also stops the TMR0 counter for something like 2 or 3 instruction cycles,= =20 IIRC. So it would be really nice if your xtal divided properly. Clocking timer-1 and timer-2 as independent oscillators is nice cause you= can=20 run a low-cost, higher-speed oscillator (like RC or even internal osc) fo= r=20 the main processing, and then use an accurate 32.768khz xtal on the secon= dary=20 oscillator for the clock timing. I believe your 18F452 has an internal o= sc=20 (no external components req'd), so I would lean towards using this latter= =20 method. Pick your secondary oscillator xtal so you get the resolution yo= u=20 need. There's lots more details in here, which the datasheet and the mid-range=20 manual explains much better than I can. Cheers, -Neil. On Thursday 05 June 2003 15:41, Peter Moreton scribbled: > Hi, I'm playing about with a PIC18F452 and trying to design a very > simple clock circuit, to show both UTC and Sidereal (astronomical) time > on a 2x16 LCD display. Before I start writing code using the C18 > compiler, I'd like to ask for opinions for crystal frequencies that > 'make sense' in a clock application. I was kindof expecting that a powe= r > of 2 crystal such as 32768 khz or better still, a 4.194304 Mhz crystal > would be sensible, as the frequency is easily divisible into 1hz. But, > then, reading up about the TIMER0/1/2/3 modules, I begin to doubt that > it matters at all, since I can load a counter value appropriate to the > xtal, and have the counter overflow, and generate an interrupt, say > every 100'th of a second. > > Is my understanding correct, that using TIMER0, accurate time can be > generated from any abitrary clock frequency? > > I noticed that TIMER0 (and also TIMER1) have the ability to be clocked > independently from the CPU clock, from a 32768 khz watch xtal, is there > any reason for this, in terms of clock applications? Would it be the > case that the 32768 khz xtal might be used when the main CPU clock had > been selected for ease of generating serial (RS232?) baud rates? > > Sorry for all the questions.... steep learning curve for me right now..= =2E > > Peter Moreton -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu