> >From what I can read of the datasheets, a prescaler is some sort of > black magic that scales down Hz to some other value. For a 16F628a > (which I'm going to work on) I can select either 1:1, 1:2, 1:4 or 1:8 > in T1CON. I'm going to use a 32768Hz-crystal for counting secs in > my app A pre-scaler is a binary ripple counter (or divider if you want to call it that) which can have the count limit or division set by s/w. If set to 1:2, you get one "increment" out for every two that go in, similarly with 1:4, 1:8 and so on. There are diagrams showing the phase relationships but it's not necessary to understand those to make it work > I want a timer-interrupt each second. 32768/4 = 8192. If I pick > prescaler 1:8 I (think I) get 1024, but I'm not sure what this value > is or how I can use it to measure one second of elapsed time. When Timer1 is used with an external crystal, the crystal frequency is not divided by 4, as the main oscillator is. Therefore you want to count the full 32768 cycles for 1 second. This means you don't have to use the pre-scaler at all To take your example above, any count less than 0x0000 (65536) can be done with a 16-bit timer like TMR1. Very close to 0x0000 can be tricky, time-wise, but when you're hundreds or thousands of counts below roll-over it's not generally a problem. The 8192 (0x2000) is loaded into the timer as -8192, which is 0x100000 - 0x2000 = 0xE000. So TMR1L would be set to 0x00 and TMR1H to 0xE0, and the pre- scaler is not needed The easiest way to get 1 second interrupts out is to clear TMR1L and set TMR1H to 0x80. ie TMR1 = 0x8000. It will take 32768 (0x8000) to get TMR1 back up to 0x0000 and generate an interrupt. Then you reload TMR1H with 0x80 (If the reload is done early in the ISR, then TMR1H will still be 0x00, and simply BSF TMR1H,7 will make it 0x80, but I can't imagine you'd be so short of time you'd need to save an instruction cycle) TMR1L has already been 0x00 (at the instant of TMR1IF being set) and is being incremented as part of the second timing, so don't touch TMR1L Oh, and don't forget to clear TMR1IF -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist