How to Use Diviner for PIC Configuration Bits (Step‑by‑Step)Configuring PIC microcontrollers requires careful setting of configuration bits (fuses) that control clock sources, watchdog timers, code protection, brown‑out reset, and other critical hardware behaviors. Diviner is a graphical tool designed to simplify reading, editing, and generating PIC configuration bits for a variety of PIC families. This step‑by‑step guide explains how to install Diviner, read a device’s current configuration, edit settings safely, generate code or header files, and verify changes on hardware.
What Diviner does and when to use it
Diviner provides a user‑friendly interface for:
- Visualizing configuration bits (instead of interpreting hex values).
- Selecting safe combinations appropriate for your application.
- Exporting configuration definitions for compilers or programmer scripts. Use Diviner when you want to avoid manual bit‑mask mistakes, accelerate setup for a new PIC project, or document configuration choices clearly.
Prerequisites
- A supported PIC device (check Diviner’s compatible device list).
- Diviner installed on your PC (Windows, macOS, or Linux builds if available).
- A PIC programmer/debugger (e.g., PICkit, ICD, or third‑party) if you plan to read/write hardware.
- Basic familiarity with PIC concepts: clock sources (HS/XT/INTOSC), watchdog timer (WDT), brown‑out reset (BOR/BOD), code protection, low‑voltage programming (LVP).
Step 1 — Install and open Diviner
- Download Diviner from the official source or trusted repository for your platform.
- Run the installer or extract the archive and launch the Diviner executable.
- On first run, review any device database updates and allow the application to update its configuration bit definitions.
Step 2 — Select your PIC device
- In Diviner’s main window, locate the device selection dropdown or search box.
- Enter the device part number (for example, PIC16F15313) and select it from the list.
- Confirm the device family; the displayed configuration fields will update accordingly.
Step 3 — Read current configuration (optional but recommended)
If you have a programmer connected:
- Connect your PIC programmer to the target board and to your PC.
- In Diviner, choose the option to read configuration from the device (often labeled “Read Device”, “Read Config”, or similar).
- Diviner will query the device and display current configuration bit settings in human‑readable terms.
- Save a copy of the read configuration as a baseline (export file or screenshot).
Why read first: it prevents accidental overwriting of important settings (like disabling low‑voltage programming permanently).
Step 4 — Understand the configuration fields
Diviner shows configuration bits grouped by function. Common groups include:
- Oscillator/clock selection: INTOSC, HS, XT, EC, etc.
- Power‑on reset / Brown‑out Reset: BOR level, enable/disable.
- Watchdog Timer (WDT): enabled/disabled, windowed WDT options.
- Code/Data Protection: code protection bits, write protection.
- Low Voltage Programming (LVP): enable/disable.
- Debug/ICSP settings: debugger enable, alternate pin assignments.
Tip: Hover tooltips or inline descriptions often explain each option and implications for operation.
Step 5 — Edit configuration safely
- Work from the saved baseline or the read values.
- Change one functional area at a time (e.g., oscillator first).
- For each change, note the consequences:
- Switching from INTOSC to HS requires an external crystal or oscillator.
- Disabling LVP removes the ability to enter low‑voltage programming if you don’t have an ICSP alternative.
- Enabling code protection may make reading device memory impossible without unlocking procedures.
- Use Diviner’s warnings: many options that could brick a device are highlighted or prompt confirmation.
Example safe changes:
- Enable internal oscillator and disable external oscillator pins if your design uses INTOSC.
- Set WDT to disabled for initial development and enable later if you need runtime reset protection.
Step 6 — Verify bit combinations
- After making changes, review the generated raw configuration bit hex values in Diviner.
- Compare generated values with device datasheet examples or with your baseline to ensure only intended bits changed.
- If Diviner supports simulation or validation, run it to check for incompatible selections.
Step 7 — Export settings for your toolchain
Diviner usually offers export options:
- Header files or #pragma configuration lines for XC8, XC16, or other compilers.
- Programmer command snippets or scripts (e.g., for pk2cmd, MPLAB IPE, or other CLI tools).
- Raw configuration hex values for manual programming.
Export examples:
- XC8 pragma: #pragma config FOSC = INTOSC, WDTE = OFF, PWRTE = ON (Diviner will format appropriately).
- MPLAB IPE: provide the configuration word(s) or a programming file with the config region.
Save exported files into your project folder so version control captures them.
Step 8 — Write configuration to the device
- Connect programmer, ensure target power and connections are correct.
- Use Diviner’s “Write Configuration” or “Program” action, or paste exported config into your programmer tool.
- If the programmer warns about disabling LVP or changing debug pins, confirm you have a recovery method (ICSP, HV programmer).
- After programming, read back the configuration to confirm the device reflects the intended settings.
Step 9 — Test on hardware
- Power cycle the target board to ensure new settings apply on cold start.
- Verify clock operation, reset behavior, and peripheral availability (some configuration changes affect pin functions).
- If the device doesn’t respond (e.g., locked out by code protection), use your recovery method or high‑voltage programming as documented by the PIC vendor.
Troubleshooting common issues
- Device won’t enter programming mode after disabling LVP: Use ICSP header or an HV programmer to recover.
- Mismatched oscillator selection: If you selected HS but didn’t provide a crystal, revert selection via programmer or use an external clock signal if supported.
- Code protection prevents reading memory: keep unprotected backups of final firmware; for development keep code protection disabled.
Best practices and tips
- Keep configuration settings in version control alongside source code.
- Comment exported pragmas or headers explaining why each non‑default option was chosen.
- Use conservative settings during development (WDT off, BOR enabled at safe level, LVP on only if required).
- Test configuration changes incrementally on jig/bench before field deployment.
- Keep the device datasheet and family reference manual handy; Diviner helps but datasheet is authoritative.
Example workflow summary
- Select device in Diviner.
- Read and save current configuration.
- Edit one group at a time, using tooltips/datasheet.
- Export config for your compiler/programmer.
- Program device and verify by reading back.
- Test hardware behavior and iterate.
If you want, I can:
- Provide sample exported pragma lines for a specific PIC part (tell me the part number and toolchain), or
- Walk through a simulated configuration change (tell me what you want to enable/disable).
Leave a Reply