EM78P5840N/41N/42N
8-Bit Microcontrollers
The following formula is used to calculate the PWM period:
⎛
⎞
1
⎜
⎜
⎟
⎟
Period =
(
PRDX +1
)
×4×
× (TMRX × Prescale value)
FOSC
⎝
⎠
Where Fosc is the system clock
7.10.5 PWM Duty Cycle (DTX: DT1H/ DT1L; DTL: DL1H/DL1L)
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 any time. However, it cannot be latched into DTL until the current
value of DLX is equal to TMRX.
The following formula is used to calculate the PWM duty cycle:
⎛
⎞
1
⎜
⎜
⎟
⎟
Duty Cycle =
(
DTX
)
×
× (TMRX × Prescale value)
FOSC
⎝
⎠
7.10.6 PWM Programming Procedure/Steps
Follow these steps in loading PRDX with the PWM period:
1) Load DTX with the PWM duty cycle
2) Enable interrupt function by writing to IOCF PAFE0, if required
3) Set the PWMX pin as output by writing a desired value to IOCC Page 0
Load a desired value to R5 Page 3 with the TMRX prescaler value and enable both
PWMX and TMRX.
7.10.7 Timer (TMRX)
The TMRX, consisting of Timer 1 (TMR1) and Timer 2 (TMR2), are 10-bit clock
counters with programmable prescalers. This is designed for the PWM module to be
set as baud rate clock generators. TMRX can be read, written, and cleared at any reset
conditions.
Product Specification (V1.0) 04.25.2006
(This specification is subject to change without further notice)
• 41