PIC PWM Generator & Waveform Analyzer

Educational Module for 8-bit Microcontroller Hardware PWM (Timer2 & CCP1)

PWM Design Parameters

Tins: 1.00 µs
Presets:
50.0%
%

PIC PWM Governing Equations

Tins(μs) = 4 / Fosc(MHz)

T(μs) = Tins × Prescaler × (PR2 + 1)

Ton(μs) = Tins × Prescaler × (CCPR1L:CCP1CON<5:4> / 4)

10-bit DC Val = CCPR1L:CCP1CON<5:4> = Duty% × 4 × (PR2 + 1)

Interactive PWM Waveform Diagram (2 Cycles)

High State (Ton) Low State (Toff)

Hover over the waveform diagram to inspect instantaneous timing parameters & amplitude.

Optimal Configuration

Hardware Register Calculations

Timer2 Prescaler 1:16
PR2 Register 249 0xF9
CCPR1L (8-bit MSB) 125 0x7D
10-Bit Duty Reg 500 0x01F4
Actual Freq: 1.00 kHz
Actual Duty %: 50.00 %
Freq Error: 0.00 %
Generated XC8 / CCS C Firmware Code
// Perform calculation to generate C code

Prescaler Comparison Table (1:1, 1:4, 1:16)

3 prescalers
Prescaler PR2 (Dec / Hex) CCPR1L 10-bit Duty Actual Freq Status Action
No calculation performed yet.