Datasheet
General purpose PWM L6460
90/139 Doc ID 17713 Rev 1
19 General purpose PWM
L6460 includes three general purpose PWM generators that can be redirected on GPIO
pins (see Chapter 22). Two of these generators (Aux_PWM_1 and Aux_PWM_2) work with
a fixed period F
OSC
/512 and have a programmable duty cycle; the other one (GP_PWM)
has a programmable base time clock and a programmable time for both high and low levels.
19.1 General purpose PWM generators 1 and 2 (AuxPwm1 and
AuxPwm2)
The Duty cycle of these PWM generators can be changed by writing the AuxPwmXCtrl bits
(where X can be 1 or 2) in the AuxPwm1Ctrl and AuxPwm2Ctrl registers. Their positive duty
cycle will change according to the equation:
According to this equation a programmed “0” value will cause a 0% duty cycle (output
always at logic level 0).
19.2 Programmable PWM generator (GpPwm)
GpPWM has a programmable base clock that can be changed by programming the
GpPwmBase[6:0] bits in the GpPwmBase register. The clock will change according to the
equation:
The high and low level duration (expressed in base clock periods), can be programmed
writing the GpPwmHigh[7:0] and GpPwmLow[7:0] bits in the GpPwmCtrl register so they will
change according to following equations:
The resulting period of the PWM will be:
and the positive duty cycle will result:
A programmed value of 0 in GpPwmHigh[7:0] and GpPwmLow[7:0] bits will force the PWM
generator output to be always at logic level “0”.
PWM_X_DUTY AuxPwmXCtrl 9:0[]/512=
PWM_BASE_PERIOD GpPwmBase 6:0[]1+()Tosc×=
High_level_Time GpPwmHigh 7:0[]PWM_BASE_PERIOD×=
Low_level_Time GpPwmLow 7:0[]PWM_BASE_PERIOD×=
Period GpPwmHigh 7:0[]GpPwmLow 7:0[]+()PWM_BASE_PERIOD+=
DutyCycle
High_level_Time
High_level_Time Low_level_Time+
---------------------------------------------------------------------------------------------- -
GpPwmHigh 7:0[]
GpPwmHigh 7:0[]GpPwmLow 7:0[]+
---------------------------------------------------------------------------------------------------------==