PWM Introduction

  • Pulse Width Modulation (PWM) is a perpheral used to generate square waves.
  • A square wave output needs a frequency and duty cycle
  • There are two PWM pins on the PIC18F4520. PWM1 is on RC2, PWM2 is on RC1 (no joke :) )
  • We'll use library functions to set the frequency (OpenPWMx) and duty cycle (SetDCPWMx)