NXP Semiconductors

UM10301

 

User Manual PCF85x3, PCA8565 and PCF2123, PCA2125

12.3 Setting the timer

The internal timer is an 8-bit countdown timer which is controlled by the timer control register. The timer counts down from a software-loaded 8-bit binary value. It can be clocked by four different source clock frequencies: 4096 Hz, 64 Hz, 1 Hz or 1/60 Hz.

This example for the PCF8563 generates an interrupt after 10 ms:

Clock to be used 4096 Hz;

Number of clock pulses needed = 0.01 x 4096 = 40;

Error = 40 / 4096 Hz – 0.01 = -234 μs;

Length of I2C-bus initialization: 3 start conditions, 3 pulses each + 9 bytes, 9 pulses each = 90 clocks @ 400 kHz = 225 μs. Creating the clock asynchronously also gives an error of up to 1 clock pulse (see Chapter 17 “First period inaccuracy when using the timer”.). The interrupt will generate an output pulse after 9.991 ms or if the counter is set to 41 the interrupt will start after 10.236 ms.

The timer is started by the acknowledge of the start timer instruction.

Table 7. Setting the timer

Sequence of commands / data to be sent

Binary (BCD)

HEX

Register

 

 

 

Address

 

 

 

 

 

 

 

 

1 0 1 0

0 0 1 0

A2

 

 

 

 

 

0 0 0 0

0 0 0 1

01

 

 

 

 

 

0 0 0 0

0 0 0 1

01

01

 

 

 

 

 

 

 

 

1 0 1 0

0 0 1 0

A2

 

 

 

 

 

0 0 0 0

1 1 1 1

0F

 

 

 

 

 

0 0 1 0

1 0 0 0

28

0F

 

 

 

 

 

 

 

 

1 0 1 0

0 0 1 0

A2

 

 

 

 

 

0 0 0 0

1 1 1 0

0E

 

 

 

 

 

1 0 0 0

0 0 0 0

80

0E

 

 

 

 

Comments

generate I2C start condition I2C slave address, write

word address 1 (control/status register 2) clear all flags, enable timer interrupt generate I2C start condition (repeated start) I2C slave address, write

Word address 0FHEX for timer value Timer value set to 40, 28HEX

generate I2C start condition (repeated start) I2C slave address, write

word address OE for timer control byte

Select clock frequency 4096 Hz and start timer generate I2C stop condition

Refer to chapter 17 “First period inaccuracy when using the timer” for further details on timer operation.

UM10301_1

 

© NXP B.V. 2008. All rights reserved.

User manual

Rev. 01 — 23 December 2008

29 of 52

Page 29
Image 29
NXP Semiconductors PCF2123, PCF85x3, PCA8565, PCA2125 user manual Setting the timer, Register