Diviner — PIC Configuration Bits Tool: Quick Setup Guide

Mastering PIC Configurations with Diviner: Step‑by‑Step Tutorial

Overview

Diviner is a configuration-bits utility for Microchip PIC microcontrollers that simplifies selecting and exporting the device configuration (fuses) required by your toolchain and programmer. This tutorial walks through installing Diviner, selecting a target PIC, setting configuration bits, validating options, and exporting configuration values for use in MPLAB X, XC compilers, or programmer command lines.

What you’ll need

  • A PIC device family and part number (e.g., PIC16F18855).
  • A development PC with internet access.
  • Diviner executable (download from the project’s distribution).
  • Your preferred toolchain (MPLAB X / XC8 / command-line programmer).

1. Install and open Diviner

  1. Download the Diviner release appropriate for your OS from the project page.
  2. Unzip or run the installer and launch the Diviner application.
  3. Confirm the app starts and displays the device selection field.

2. Select your PIC device

  1. In the device selector, type your target part number and pick it from the dropdown.
  2. Verify the device family and package match your hardware.

3. Understand configuration bit groups

  • Device configuration bits are organized by functional groups (oscillator, watchdog timer, reset, code protection, brown-out reset, etc.).
  • Diviner presents these groups with human-readable labels and the underlying bit names/values.

4. Set configuration options

  1. Work through each group top-to-bottom to avoid missing dependencies.
  2. For oscillator: choose the oscillator mode (HS, XT, EC, INTOSC, etc.) consistent with your circuit.
  3. For watchdog timer (WDT): enable or disable; set WDT postscaler if available.
  4. For power-on reset / brown-out reset: enable thresholds that match your supply design.
  5. Code protection and debug: enable only if you intend to lock the device; enable debug flags when using debugging tools.
  6. Peripheral-specific options: set CCP, comparator, ECCP, or other peripheral configuration bits as required.

5. Use tooltips and documentation

  • Hover or click help icons in Diviner to see short explanations for each option.
  • Cross-check ambiguous settings with the device datasheet.

6. Validate and resolve conflicts

  1. Diviner typically warns about incompatible selections (for example, selecting an internal oscillator while enabling an external clock mode).
  2. Address warnings by choosing compatible options or consulting the datasheet.

7. Preview raw configuration words

  • Switch to the raw view to see configuration words (e.g., CONFIG1, CONFIG2) and binary/hex values.
  • Confirm the generated hex matches expectations (e.g., unprogrammed bits are 1s).

8. Export configuration for your toolchain

  1. Choose the export format: MPLAB-X header, XC compiler pragmas, assembler directives, or raw hex/command-line flags.
  2. Save or copy the output. Common outputs include:
    • #pragma config lines for XC8/C18
    • __CONFIG macros or assembler CONFIG directives
    • A .inc or header file for use in assembly or older toolchains
    • Direct hex values for use with command-line programmers

9. Integrate into your project

  • Paste or include the exported lines into your source (top of main.c or a dedicated config.h).
  • For MPLAB X, add the header file or ensure the pragmas are present before compilation.

10. Program and verify on hardware

  1. Build the project and program the device using your programmer/debugger.
  2. Verify expected runtime behavior (clock, watchdog, peripheral enablement).
  3. If issues appear, revisit Diviner settings and consult the datasheet.

Troubleshooting checklist

  • Incorrect oscillator behavior: confirm oscillator mode and PLL settings.
  • Watchdog unexpected resets: check WDT enable and timeout settings.
  • Code protection prevents programming: disable code protection during development.
  • Programmer reports configuration mismatch: ensure the exported hex uses the correct bit order and polarity for your programmer.

Tips & best practices

  • Keep configuration bits in a single source file to avoid duplication.
  • Comment exported pragmas with the chosen human-readable settings.
  • Use version control for configuration headers.
  • For teams, document why non-default configuration choices were made.

Quick example (conceptual)

  • Target: PIC16F18855
  • Oscillator: INTOSC (internal oscillator)
  • WDT: Disabled
  • BOR: Enabled at recommended threshold
  • Code Protection: Off (development)
  • Export: XC8 #pragma config lines — include at top of main.c

Conclusion

Diviner streamlines translating human configuration choices into the exact configuration words needed by PIC toolchains and programmers. By following a methodical flow—select device, set groups, validate, preview raw words, export, and

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *