6.3.3.4 PWM Period and Duty Cycle Limits

For each of the four PWM modules, the period and duty cycle settings share the same limits:

Period

The period register can have values from 0 (0x0000) to 65,535 (0xFFFF), enabling the user to set the PWM signal’s frequency within the operating frequency of 25 MHz.

Duty Cycle

The duty cycle register also accepts values from 0 (0x0000) to 65,535 (0xFFFF), allowing the user to control the width of the pulse within the period and, consequently, the PWM signal’s duty cycle as a fraction of the total period.

Calculating Period and Duty Cycle

To calculate the period value (P) from a desired time in milliseconds (T), use the following equation:

P = (F * T) / 1000

Where:

  • P = Period
  • F = Frequency (in Hz)
  • T = Desired period time (ms) 

To calculate the raw duty cycle value (DC) based on the desired ON time percentage (DCP), use the following equation:

DC = (DCP * P) / 100

Where:

  • DC = Duty cycle value (Hex)
  • DCP = Duty cycle percentage (Desired ON time percentage)
  • P = Period

Example Calculation for 2 ms Period:

Calculating value for 2 ms period:

P = (25,000,000 Hz * 2 ms)/1000 = 50,000

50,000 converted to hex = 0xC350

Example Calculation for Duty Cycle based on 2ms Period

Calculating 30% DC using previously calculated period:

DC = (30 * 50,000) / 100 = 15,000

15,000 converted to hex = 0x3A98