PWM Calculator

Calculate CCP register values for specific PWM duty cycles and frequencies. Perfect for motor control applications.

Input Parameters

Calculation Results

PR2 Value: -
CCPR1L Value: -
CCP1CON Bits: -
Actual PWM Frequency: -
Actual Duty Cycle: -
Resolution (bits): -

Assembly Code:

; PWM configuration will appear here

How PWM Works

PWM (Pulse Width Modulation) uses Timer 2 and the CCP module to generate variable duty cycle signals:

PWM Frequency = FOSC / (4 × Prescaler × (PR2 + 1))
Duty Cycle = (CCPR1L:CCP1CON<5:4>) / (4 × (PR2 + 1)) × 100%

The CCPR1L register contains the high 8 bits of the duty cycle, while CCP1CON bits 5:4 contain the low 2 bits for 10-bit resolution.