Academic Program

Setup

Setup

Step by Step Instructions

Using the MPLAB® Code Configurator (MCC), this project generates the code to control the brightness of an LED using a hardware PWM peripheral to generate the variable on/off time at a very high rate. This on/off frequency averages out to appear as a variable brightness on the LED.

proj5bd.jpg

 

The project uses:

  • PIC16F18875
  • HPC Curiosity Board
  • MPLAB X IDE
  • MPLAB Code Configurator (MCC) plug-in
  • MPLAB XC8 Compiler

To follow along with these steps, MPLAB X should be open and the HPC Curiosity Board connected to the computer through a USB cable.

Step 1 - Create a new 'standalone' project in MPLAB X for a PIC16F18875.

If this is your first time creating an MPLAB X project, please visit the "Create a Standalone Project" page to follow a step-by-step instruction on how to do this.

Step 2 - Open the MPLAB Code Configurator under the Tools > Embedded menu of MPLAB X IDE.

mcclaunch.png

 

Step 3 - Select the peripherals for your project. In this first project, the following peripherals need to be selected:

  • System Module
  • Interrupt Module
  • Pin Module
  • TMR2
  • PWM6

These modules will automatically be included when you launch the MCC, with the exception of TMR2 and PWM6. TMR2 and PWM6 need to be added from Device Resources. Just click on Timer and then double-click on Timer 2 to add it to the project. Click on the PWM and then double click PWM6. The result should look like the picture below:

proj5per.png