Download: Examples - PWM.zip
The following example programs are available to demonstrate the basic principles of using a PWM module:
Example program that demonstrates the use of a PWM output. The output will be cycled from 0%, 25%, 50%, 75% and 100% every 5 seconds. If and LED or DC motor driver are connected to the pin, you will see the LED go from dim to bright and the DC motor turn slow to fast.
* An LED or DC motor driver connected to PB6
* Connect PB6 to an oscilloscope to see the effect of an PWM output graphically.
Example program that demonstrates the use of multiple PWM outputs. Each PWM output will individually be ramped up from 0 to 100%. The signals will be 25% out of phase for demonstration purposes.
* LEDs connected to:
PB6 (TIM4_CH1)
PD13 (TIM4_CH2)
PD14 (TIM4_CH3)
* Connect the PWM outputs to an oscilloscope to see the effects graphically.