EM78P417N/418N/419N
8-Bit Microprocessor with OTP ROM
6.8.4 PWM Duty Cycle (DTX: DT1H/ DT1L, DT2H/ DT2L and
DT3H/DT3L; DLX: DL1H/DL1L, DL2H/DL2L
and DL3H/DL3L )
The PWM duty cycle is defined by writing to the DTX register, and is latched from DTX
to DLX while TMRX is cleared. When DLX is equal to TMRX, the PWMX pin is cleared.
DTX can be loaded anytime. However, it cannot be latched into DLX until the current
value of DLX is equal to TMRX.
The following formula describes how to calculate the PWM duty cycle:
Duty Cycle = (DTX) * (1/Fosc) * CLKS/2 * (TMRX prescale value )
Example:
DTX=10;Fosc=4MHz;CLKSbitofCodeOptionRegister=0(2oscillator
periods); TMRX(0,0,0)=1:2, then Duty Cycle=10 * (1/4M) * 2/2 * 2
=5us
6.8.5 Comparator X
Changing the output status while a match occurs, will set the TMRXIF flag at the same
time.
6.8.6 PWM Programming Process/Steps
Load PRDX with the PWM time period.
1. Load DTX with the PWM Duty Cycle.
2. Enable interrupt function by writing IOCF0, if required.
3. Set PWMX pin to be output by writing a desired value to IOC80.
4. Load a desired value to IOC51 with TMRX prescaler value and enable both PWMX
and TMRX.
6.9 Timer
6.9.1 Overview
Timer1 (TMR1), Timer2 (TMR2), and Timer3 (TMR3) (TMRX) are 10-bit clock counters
with programmable prescalers. They are designed for the PWM module as baud rate
clock generators. TMRX can be read only. The TIMER1, TIMER2, and TIMER3 will
stop running when sleep mode occurs with AD conversion not running. However, if AD
conversion is running when sleep mode occurs, the TIMER1, TIMER2 and TIMER3 will
keep on running.
52 •
Product Specification (V1.0) 06.23.2005
(This specification is subject to change without further notice)