TTP258
TonTouchTM
Preliminary
P-5: 16 bits Timer/Counter
Two sets TCP can be cascaded to form a 16-bit timer/counter when TCP2
chooses TCP1OV as clock source (TCP2S1=1 & TCP2S0=1). In the 16-bit timer
application, data load is controlled by writing TCP1EN=1 , then user should
enable the TCP2EN at first, then using TCP1EN to control the starting or
stopping counting of 16-bit timer/counter. The rising TCP2OV will reload the
contents in the pre-load register into timer/counter, if TCP1LD in TCP1C &
TCP2LD in TCP2C are enabled. The interrupt feature is different, in this case,
the TCP1 INT will be inhibit when TCP1OV occur, the TCP2 INT is normally.
Figure: 16 Bit Timer/Counter Configuration
.Timer
When TCPx works as a Timer, user needs give the preload data TCPxD for
periodic interrupt. After initial setting, user starts the TCPx counting by setting
TCPxEN=1, the TCPx cycle period is:
Tc = (selected clock cycle) * (256) if TCPxD=00H
Tc = (selected clock cycle) * (TCPxD) otherwise
When 16 bits timer/counter:
Tc = (selected clock cycle) * (65536) if TCP1D=00H & TCP2D=00H
Tc = (selected clock cycle) * (TCP2D*256+TCP1D) otherwise
When user writes data to the TCPxD, the data just keep in TCPxL/H. During
the TCPxEN=1 command executed, the TCPxD’s complement value will load
into counter TCPx as initial value and start the timer function. Necessary
TCPxLD=1, timer run with reload feature as TCPx up counts and reaches the
value of “FFH” or 255 for TCPx. At the same time, interrupt request flag TCPxF
will set activated, if software enables the corresponding interrupt enable bit,
INT hardware will cause MCU interrupt service routine.
16’/04/06
Page 23 of 44
Ver.: 1.2