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

Page 29

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

Image 29
Contents Abstract Info Content KeywordsDocument information NXP Semiconductors Contact informationRevision history Rev Date DescriptionIntroduction Features Address Register name Bit Register overview PCF8563Comparison Event counter modeComparison of six real time clocks FeaturesVoltage-low detector Power-on reset PORPower-on reset Oscillator-stop detection OscillatorVoltage-low detection Overview of internal and external oscillator capacitors Pierce Oscillator equivalent diagramOscillator frequency determining components UM10301 + C Parameter Value Unit Source Typical values for crystal and surrounding capacitorsOscillation allowance Using an external oscillatorCrystal and crystal selection Modes which don’t work Effect of temperature− f nom Capacitors and capacitor selection Accuracy Influences on time accuracy Oscillator tuning Oscillator tuning 10.1 PCF2123 Offset register Century tracking Century and leap year, Daylight Saving TimeYear and leap year tracking Daylight Saving Time DSTBlock Diagram PCF8563 Initialization and setting of alarm and timerInitialization of the RTC and setting the time Setting the alarm AlarmBinary BCD Register Comments AddressAlarm function Register Setting the timerSetting the timer Lithium Primary cells Backup power supplyBackup circuit using primary lithium cell NiCd and NiMH secondary batteries Backup circuit using secondary cell NiCd or NiMH13.3 Capacitors Charging the backup capacitor Some suggestions for diode D1 Diode selection1N4148 BAS716 BAS116 BAV170PCB layout guidelines PCB layout proposal for PCF8563 using leaded components Partial circuit switch down Protection diodes Hints to keep power consumption low0007 Rpmax as a function of bus capacitance 8473 ⋅ C bApplication diagram 2, SPI interface Application diagram 1, I2C-bus interfaceTimer delays First period inaccuracy when using the timerTimer Source clock frequency Delay for n = General countdown timer behaviourTimer source clock Minimum timer period Maximum timer period First period delay for timer counter value nTiming requirements for I2C read and write I2C interface Block diagram I2C interface and Time countersSequence of events example Read Oscillator startup time Checking for oscillation TroubleshootingNo communication via I2C-bus Wrong time and date, wrong clock speed ReferencesDefinitions Legal informationDisclaimers TrademarksContents