### OPTION - OPTION Control register

Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0
!RBPU | INTDG | T0CS | T0SE | PSA | PS2 | PS1 | PS0

Items in red are not relevant to the timer.

### T0CS - TIMER0 Clock Source

If this bit is clear it tells the PICmicro to use bit 4 of PORTA as the clock source. You would clear this bit if you wanted to use the timer to count pulses. The timer will increment when it sees an edge on the input signal. If you want to increment on a rising (i.e. low to high transition) edge you must clear bit T0SE. To increment on a falling edge you must set bit T0SE. Note that the timer will generate interrupts (if enabled) irrespective of the clock source. You must of course have configured this port as an input (using TRISA) for this to work.

If this bit is set it tells the PICmicro to use the instruction clock as the clock source. This is updated each time the PICmicro finishes executing an instruction. The PICmicro takes four clock pulses to complete an instruction, and so the clock is updated at 1/4 of the speed of the crystal. For the PICmicro development board, which has a 3.2768 MHz crystal, this means that the clock updates at 819,200 Hz.

### T0SE - TIMER0 Source Edge

This bit selects the edge direction of signals which will cause the counter to count if the source is set to bit 4 of PORTA. If the bit is set the timer will increment on the rising edge of a pulse. If the bit is clear the timer will increment on the falling edge of a pulse. If the timer is set to use the instruction clock as the source this bit has no meaning.

### PSA - PreScaler Assignment Bit

The pre-scaler lets you control the rate at which the timer counts. It divides the timer input frequency by a particular power of 2, so that you can slow down the clock. There is only one prescaler on the PICmicro, and it is shared between the watchdog timer (of which more later) and the timer. If this bit is cleared the PSA is assigned to the clock.

### PS2, PS1, PS0 - PreScaler control bits

These bits allow you to select one of eight pre-scaler values. These are the numbers which the clock is divided by. The assignments are as follows:

PS2 | PS1 | PS0 | divide by
0 | 0 | 0 | 2
0 | 0 | 1 | 4
0 | 1 | 0 | 8
0 | 1 | 1 | 16
1 | 0 | 0 | 32
1 | 0 | 1 | 64
1 | 1 | 0 | 128
1 | 1 | 1 | 256

For example, the PICmicro development board crystal runs at 3.2768 MHz giving an instruction clock speed of 827,600 Hz. If I set the pre-scaler to its maximum value (111) the clock increments at 819,200/256 = 3,200 Hz. If I generate an interrupt each time the clock overflows (i.e. after 256 counts) I will get 3,200/256=12.5 interrupts per second.