Generating PWM with PIC18F4520 Revision as of 15:11, 10 August 2016 by Sharana
Please check this tutorial for detailed explanation on PIC18F4520 PWM module.
PIC18F4520 PWM Module
PIC18F4520 microcontroller has two independent CCP(Capture/Compare/PWM) modules, named as CCP1 and CCP2. Each CCP module has two 8-bit resistors(CCPxH,CCPxL) that can be use as:
- 16 bit Capture Register
- 16 bit Compare Register
- 10-bit PWM Register.
In this tutorial we will be discussing only the PWM part of CCP. PIC has 2PWM module with a resolution of 10-bits.
Below tables shows the PWM module of PIC.
|PWM Channel||Port Pin||Control Register||Duty Cycle Register||Period Register|
Below is the example to vary the brightness of the LED(PC.2) using PWM.
Progarm to generate the PWM signals of 25% & 75% duty cycle.