This repository contains an example of MCC generated 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.
- TB3270 - Getting Started with PWM Using CCP on PIC18
- PIC18-Q10 Product Family Page
- PIC18F47Q10 Data Sheet
- PIC18F47Q10 Code Examples on GitHub
- MPLAB® X IDE 5.30 or newer (microchip.com/mplab/mplab-x-ide)
- MPLAB® XC8 2.10 or newer (microchip.com/mplab/compilers)
- MPLAB® Code Configurator (MCC) 3.95.0 or newer (microchip.com/mplab/mplab-code-configurator)
- MPLAB® Code Configurator (MCC) Device Libraries PIC10 / PIC12 / PIC16 / PIC18 MCUs 1.79.0 or newer (microchip.com/mplab/mplab-code-configurator)
- Microchip PIC18F-Q Series Device Support 1.3.89 or newer (packs.download.microchip.com/)
- PIC18F47Q10 Curiosity Nano (DM182029)
- one RGB LED either common anode (default) or common cathode, resistors, wires and optionally a breadboard
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)
Assemble the circuit, then run the MCC generated 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:
This project showcases how to configure the PIC18F47Q10 microcontroller using MCC for generating three PWM signals and duty-cycle update during interrupt.