Skip to content

microchip-pic-avr-examples/pic18f47q10-cnano-pwm-rgb-led-bare

Repository files navigation

MCHP

PIC18F47Q10 PWM RGB-LED Using Interrupts

Objective:

This repository contains an example of bare-metal code for PWM as described in TB3270 - Getting Started with PWM Using CCP on PIC18 document from Microchip.
The PIC18F47Q10 features four 10-bit PWM generators. In this demo, the CCP1, CCP2 and PWM3 peripherals in conjunction with TMR2 are used to produce PWM signals featuring a color game on an RGB LED. Three GPIO pins are used as outputs: RB0, RB3 and RD0.

Related Documentation

Software Used

Hardware Used

  • PIC18F47Q10 Curiosity Nano (DM182029)
  • one RGB LED either common anode (default) or common cathode, resistors, wires and optionally a breadboard

Setup

The PIC18F47Q10 Curiosity Nano Development Board is used as the test platform.


The following configuration is done for this example:

  • RB0 pin - Configured as digital PWM output (PWM1)
  • RB3 pin - Configured as digital PWM output (PWM2)
  • RD0 pin - Configured as digital PWM output (PWM3)

Operation

Hardware Setup

Assemble the circuit, then build and run the code. The PWM frequency is fixed 7.8kHz on all three outputs while the PWM's duty-cycles are varied from minimum to the maximum during interrupt routine, like in the presented picture:

Timing diagram

Summary

This project showcases how to configure the PIC18F47Q10 microcontroller for generating three PWM signals and duty-cycle update during interrupt.