Skip to content

This repository contains the project that comes preloaded on the PIC16F13276 Curiosity Nano board. It contains a simple state machine demo of the Configurable Logic Block (CLB).

License

Notifications You must be signed in to change notification settings

microchip-pic-avr-examples/pic16f13276-cnano-out-of-box-code-mplab-mcc

Repository files navigation

Microchip Technologies Inc.

Curiosity Nano Out-of-the-Box — Use Case for CLB Using the PIC16F13276 Microcontroller With MCC Melody

This repository provides an MPLAB® X project that comes preloaded on the PIC16F13276 Curiosity Nano Evaluation Kit when the user first plugs it in. It consists of a state machine demonstration of the Configurable Logic Block (CLB) peripheral that controls the behavior and/or brightness of the on-board LED.

Related Documentation

More details and code examples on the PIC16F13276 can be found at the following links:

Software Used

Hardware Used

Operation

To program the Curiosity Nano board with this MPLAB X project, follow the steps provided in the How to Program the Curiosity Nano Board chapter.

Concept

The CLB peripheral on the PIC16F13276 acts as a button debouncer and state machine for the LED. On power-up, the LED blinks at (nominally) 7.8 Hz. All other states of the state machine change the brightness of the LED via Pulse Width Modulation (PWM) dimming, which is synthesized inside the CLB as well. The push button, SW0, on the Curiosity Nano is debounced within the CLB and used to advance the state machine. The CLB circuit is presented in the image below:

The table below shows the behavior for each button press.

State LED Behavior
0 The LED blinks at (nominally) 7.8 Hz
1 Brightness level 1 (12.5%)
2 Brightness level 2 (25%)
3 Brightness level 3 (37.5%)
4 Brightness level 4 (50%)
5 Brightness level 5 (62.5%)
6 Brightness level 6 (75%)
7 Brightness level 7 (87.5%)

Note: The percentages are calculated based on the active LOW condition.

Setup

The following peripheral and clock configurations are set up using the MPLAB Code Configurator (MCC) Melody for the PIC16F13276:

  1. Configuration Bits:

    • CONFIG1:
      • External Oscillator Selection bits: Oscillator not enabled
      • Reset Oscillator Selection bits: HFINTOSC (1MHz)
      • VDD Range Analog Calibration Selection bit: Internal analog systems are calibrated for operation between VDD = 1.8 - 3.6V
    • CONFIG3:
      • WDT Operating Mode bits: WDT Disabled, SEN is ignored
  2. CLB Synthesizer Library:

    • Enable CLB: Enabled
    • Clock Selection: MFINTOSC 32 kHz
    • Clock Divider: Divide clock source by 64
  3. CRC:

    • Auto-configured by CLB
  4. Pin Grid View:

    • CLBPPSOUT0: RC2 (LED)
    • CLBIN0PPS: RE1 (SW0 - requires Weak Pull-Up (WPU) enable)

Demo

In the demo below, each press of the SW0 button advances the state machine, changing the behavior or brightness of the on-board LED on the Curiosity Nano board.

GIF of Demo

Summary

The CLB peripheral on the PIC16F13276 device manages button debouncing and LED state control, including PWM dimming, for the Curiosity Nano kit. The preloaded project demonstrates these features through a state machine that changes the LED’s behavior with each button press.


How to Program the Curiosity Nano Board

This chapter demonstrates how to use the MPLAB X IDE to program a PIC® device with an Example_Project.X. This is applicable to other projects.

  1. Connect the board to the PC.

  2. Open the Example_Project.X project in MPLAB X IDE.

  3. Set the Example_Project.X project as main project.
    Right click the project in the Projects tab and click Set as Main Project.

  4. Clean and build the Example_Project.X project.
    Right click the Example_Project.X project and select Clean and Build.

  5. Select PICxxxxx Curiosity Nano in the Connected Hardware Tool section of the project settings:
    Right click the project and click Properties.
    Click the arrow under the Connected Hardware Tool.
    Select PICxxxxx Curiosity Nano (click the SN), click Apply and then click OK:

  6. Program the project to the board.
    Right click the project and click Make and Program Device.



Menu

About

This repository contains the project that comes preloaded on the PIC16F13276 Curiosity Nano board. It contains a simple state machine demo of the Configurable Logic Block (CLB).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published