|
There is a timer that can be
driven from an external source or the internal 2MHz oscillator. The
value of the timer register can be read from the I2C bus or the output
can be fed to an external pin. The external pin will toggle at each
overflow of the register.
The timer is working all of
the time but by default it is set to get it’s input from pin 17 so
reading the timer value with command 13 will not reveal any changes
unless there is some change on pin 17 which is set to input at reset.
The timer consists of an 8 bit register and an 8
bit presaler. The values of the prescaler can be set to the following:
|
Value |
Rate |
|
0 |
1:2 |
|
1 |
1:4 |
|
2 |
1:8 |
|
3 |
1:16 |
|
4 |
1:32 |
|
5 |
1:64 |
|
6 |
1:128 |
|
7 |
1:256 |
|
8 |
Off (1:1) |
Note that value 8 will turn off the prescaler
and allow the clock source to go straight to the timer counter.
The
timer value can be loaded with any value from 0 to 230. This value is
loaded into the counter which then increments until it overflows at
value 255. At this point, if set the output at pin 6 will toggle and the
value will be loaded into the timer again.
The result of this is that a value of 0 will give the largest delay
(lowest frequency) and 230 will give the highest delay.
|
Prescale |
Timer |
Period
at 6 |
|
8 |
230 |
50uS |
|
8 |
0 |
275uS |
|
7 |
0 |
65mS |
This table gives some examples
of the output at pin 6 when the internal clock is used. The period is
one full cycle, i.e. pin 6 goes from low to high and then back to low.
See the scope output: this is
for the lowest frequency when the prescaler is set at 7 and the timer is
set to 0. The period shown in Figure 2 is
65mS.

Command 13 will automatically
set pin 6 (i/o 3) to be an output and using command 2 to set it either
high or low will make no difference. |