Scott Horton wrote: > Could someone give me a simple (if possible) explanation of the what > is the "pre-scaler" Scott: What follows is a slightly-edited version of a message I posted here a year or so ago. I hope it helps. The RTCC (or "TMR0", if you prefer; I'm going to refer to it as "RTCC" in this message) has four components: The clock input (either from the RTCC pin or from the internal instruction clock), the RTCC prescaler, the RTCC register, and the RTCC interrupt flags (GIE, T0IE, and T0IF). CLOCK INPUT: I'm assuming that you're using the internal instruction clock as your RTCC input, and that your PIC is running at 4 MHz. Since there's an internal divide-by-4 between the oscillator frequency and the instruction clock, this means that instruction clocks occur at a 1 MHz rate. PRESCALER: The RTCC prescaler is set (via 4 bits in the OPTION register) to divide-by-1, -2, -4, -8, -16, -32, -64, -128, or -256. The RTCC input clock (1 MHz in your case) is passed to the prescaler, whose divided-down output is then fed to the RTCC register. In your case, if the RTCC prescaler is set to divide-by-4, for instance, the prescaler will send a 250 KHz clock to the RTCC register. RTCC REGISTER: The RTCC register can be preloaded with any 8-bit value that you like. Each clock pulse from the prescaler increments the contents of the RTCC register. When the value in the RTCC register rolls over from 0xFF to 0x00, the T0IF flag is set (the RTCC register continues to be incremented on every pulse from the prescaler, though). INTERRUPT FLAGS: If the GIE and T0IE flags are set when the T0IF flag is set, an interrupt is generated, the GIE bit is automatically cleared (to temporarily prevent further interrupts while your interrupt routine is executing), and the PIC jumps to the "interrupt vector" at location 0x04. Your interrupt-service routine at that location should check the T0IF flag to determine the source of the interrupt, then must clear the T0IF flag to prevent the PIC from immediately jumping back to the interrupt routine as soon as interrupts are re-enabled. At this point in the interrupt routine, you can re-load the RTCC with any appropriate value. When you're finished handling the interrupt, your code should execute a RETFIE instruction, which will automatically set the GIE bit to re-enable interrupts and return to your main program. -Andy === Andrew Warren - fastfwd@ix.netcom.com === Fast Forward Engineering, Vista, California === http://www.geocities.com/SiliconValley/2499