EM78P5840N/41N/42N
8-Bit Microcontrollers
The following figure shows the TMRX block diagram.
Fosc
1:2
To PWM1IF
1:8
1:32
1:64
MUX
reset
Period
Match
TMR1X
Comparator
T1P0 T1P1
T1EN
PRD1
Data Bus
Data Bus
PRD2
T2P0 T2P1 T2EN
Comparator
reset
Period
Match
Fosc
1:2
TMR2X
1:8
1:32
1:64
MUX
To PWM2IF
*TMR1X = TMR1H + TMR1L;
*TMR2X = TMR2H +TMR2L
Figure 7-9 TMRX Block Diagram
Where:
Fosc: Input clock
Prescaler (T1P0~T1P1 & 21P0~T2P1): Options of 1:2, 1:8, 1:32, and 1:64 are defined
by TMRX. It is cleared when any type of reset occurs.
TMR1X & TMR2X: Timer X register. TMRX is incremented until it matches with the
value of PRDX, and then it is reset to “0”. TMRX cannot be read.
PRD1 & PRDX: PWM period register
When defining TMRX, refer to the related registers for its operation as indicated in the
prescaler register. Make sure that the PWMX bits are disabled if their related TMRXs
are enabled. That is, Bit 6 of the PWMCON register must be set to “0.”
Related Control Registers (R5 PAGE3) of TMR1 and TMR2
Bit 7
PWM2E
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
PWM1E
T2EN
T1EN
T2P1
T2P0
T1P1
T1P0
Perform the Timer programming procedures as follows:
1) Load PRDX with the TIMER period
2) Enable the interrupt function by setting IOCF Page 0, if required
3) Load a desired value to PWMCON with the TMRX prescaler value, enable TMRX,
and then, disable PWMX.
42 •
Product Specification (V1.0) 04.25.2006
(This specification is subject to change without further notice)