Control LEDs with Pulse-Width Modulation (PWM)

Last modified by Microchip on 2023/11/09 09:02

There are multiple ways to generate Pulse-Width Modulation (PWM) control signals to control power circuits such as an LED driver.

  • Devices with the Capture-Compare-PWM (CCP) module can generate PWM signals to control power circuits using an on-chip digital timebase. The signal pulse width is controlled by the MCU clock and duty cycle register.
  • The Enhanced CCP (ECCP) module allows one PWM signal to control two or four output pins for half-bridge or H-bridge control, respectively.
  • Devices that have a comparator and the ECCP module can use the comparator signal to control the turn-off time of the PWM signal.
  • Devices with comparators and a PWM Switched Reluctance (SR) latch can use comparator signals and/or clock pulses to turn the latch output on and off.
  • An external PWM peripheral Integrated Circuit (IC) may be used. This option is useful when additional high-speed PWM channels are required.
  • PWM signals can be generated using software and I/O pins. This option is less costly when PWM frequency and duty cycle resolution requirements are not too high. A PIC® microcontroller with an on-chip comparator such as the PIC12F609 can be used to implement a simple LED driver. The PIC12HV609 has an internal regulator, allowing operation from a Direct Current (DC) bus that is higher than 5V.

8-, 14-, and 20-Pin PIC® Microcontroller Mixed Signal Features

DevicePinsVoltage ReferenceComparatorOp AmpsADCDigital PWM ModulePWM SR Latch

HV part numbers have an internal shunt voltage regulator.

Back to top

Buck LED Driver Using a PIC12HV615 On-Chip Comparator

LED driver comparator schematic diagram

Back to top.

RGB Color LED Application Using PIC12HV615

RGD application schematic diagram

Back to top.

Learn More

Back to top.