![Sino Wealth SH79F3283 Скачать руководство пользователя страница 55](http://html1.mh-extra.com/html/sino-wealth/sh79f3283/sh79f3283_manual_1283063055.webp)
SH79F3283
55
7.8.5 Timer5
Timer5 is a 16-bit auto-reload timer. It is accessed as two cascaded data registers: TH5 and TL5. It is controlled by the
T5CON register. The interrupt can be enabled by setting ET5 bit in IEN0 register (Refer to
interrupt
Section for details).
When writing to TH5 and TL5, they are used as timer load register. When reading from TH5 and TL5, they are used as timer
counter register. Setting the TR5 bit enables Timer5 to count up. The timer will overflow from 0xFFFF to 0x0000 and set the
TF5 bit. This overflow also causes the 16-bit value written in timer load register to be reloaded into the timer counter register.
Writing to TH4 also can cause the 16-bit value written in timer load register to be reloaded into the timer counter register.
Read or write operation to TH5 and TL5 should follow these steps:
Write operation: Low bits first, High bits followed.
Read operation: High bits first, Low bits followed.
Timer5 Modes
Timer5 has one operating modes: 16-bit auto-reload timer.
Mode0: 16 bit Auto-Reload Counter/Timer
Timer5 operates as 16-bit counter/timer in Mode 0. The TH5 register holds the high eight bits of the 16-bit counter/timer, TL5
holds the low eight bits. As the 16-bit timer register increments and overflows from 0xFFFF to 0x0000, the timer overflow flag
TF5 (T5CON.7) is set and the 16-bit value in timer load register are reloaded into timer counter register, and an interrupt will
occur if Timer 5 interrupts is enabled.
Setting the TR5 bit (T5CON.1) enables the timer. Setting TR5 does not clear the counter data of Timer4. The timer load
register should be loaded with the desired initial value before the timer is enabled.
TF5
The Block Diagram of Mode 0 of Timer 5
TL5
TH5
Increment Mode
0:Switch Off
1:Switch On
16 bit Counter
Interrupt
Request
Overflow
Flag
TR5
System Clock
Prescaler
1,8,64,256
T5PS[1:0]