![](http://datasheet.mmic.net.cn/30000/M38223E4-XXXHP_datasheet_2360327/M38223E4-XXXHP_135.png)
2.3 Timer X and timer Y
APPLICATION
2–69
3822 GROUP USER’S MANUAL
sReal time port function
Figure 2.3.26 shows an example of setting registers for using the real time port (referred as RTP)
function.
Fig. 2.3.26 Example of setting registers for using real time port
P5D : Port P5 direction register [Address B16]
Port P5 direction register
b7
b0
b2, b3 : Bits corresponding to port P52 (RTP0) and P53 (RTP1)
0 : Input mode
1 : Output mode
Set timer X stop control bit of timer X mode register to “0” to start counting
Set count value (low-order) to timer X (low-order) (TXL) [Address 2016]
Set count value (high-order) to timer X (high-order) (TXH) [Address 2116]
TXM : Timer X mode register [Address 2716]
b0 : Timer X write control bit
0 : Write value in latch and timer
1 : Write value in latch only
b7
b0
Setting of timer X mode register
Select real time ports or others
b1 : Real time port control bit
1 : Real time port function valid
1
b2 : Data storage bit for real time port (RTP0)
b3 : Data storage bit for real time port (RTP1)
b4, b5 : Timer X operating mode bits
0 0 : Timer mode
0 1 : Pulse output mode
1 0 : Event counter mode
1 1 : Pulse width measurement mode
b6 : CNTR0 active edge switch bit
CNTR0 interrupt
0 : Falling edge active
1 : Rising edge active
Pulse output mode
0 : Start at initial level “H” output
0 : Start at initial level “L” output
Event counter mode
0 : Rising edge active
1 : Falling edge active
Pulse width measurement mode
0 : Measure “H” level width
1 : Measure “L” level width
b7 : Timer X stop control bit
1 : Count stop
[Notes on use]
Notes 1: After reset release, port P5 direction register is set for the input mode, so pins P52/RTP0
and P53/RTP1 operate as ordinary input ports. For using as real time ports, be sure to set
the corresponding bits of the port P5 direction register for the output mode.
2: Change RTP output data as required, for example, by using an interrupt.
3: Do not change ports P52 and P53 selected as RTP into input pins during RTP operation.
1