5.2.4 4-byte Config Bits Registers with Clock Switching

Also includes Fail Safe, Watchdog, and Debug settings

5.2.4.1 Introduction

The Configuration settings allow the user to select the oscillators, reset sources, memory protection, clock switching, fail-safe clocks, and watchdog timer settings from the several options available on the device. They are latched in place at the power-up and also after programming of the device.

5.2.4.2 Supported Device Families

PIC16(L)F183xx

5.2.4.3 Required Header Files:

#include "mcc_generated_files/system/config_bits.h"

5.2.4.4 Module Documentation

5.2.4.4.1 CONFIGBITS Driver

This file contains the API prototype for the Configuration Bits driver.

Module description

This file contains the API prototype for the Configuration Bits driver.

Version: Driver Version 1.0.0
Note: The below code is an example code only and the value for each config bit setting will vary depending on the setup on the Configuration Bits module.

//CONFIG1
#pragma config FEXTOSC = ECH    // FEXTOSC External Oscillator mode Selection bits->EC (external clock) above 8 MHz
#pragma config RSTOSC = EXT1X    // Power-up default value for COSC bits->EXTOSC operating per FEXTOSC bits 
#pragma config CLKOUTEN = OFF    // Clock Out Enable bit->CLKOUT function is disabled; I/O or oscillator function on OSC2
#pragma config CSWEN = ON    // Clock Switch Enable bit->Writing to NOSC and NDIV is allowed
#pragma config FCMEN = ON    // Fail-Safe Clock Monitor Enable->Fail-Safe Clock Monitor is enabled

//CONFIG2
#pragma config MCLRE = ON    // Master Clear Enable bit->MCLR/VPP pin function is MCLR; Weak pull-up enabled
#pragma config PWRTE = OFF    // Power-up Timer Enable bit->PWRT disabled
#pragma config WDTE = OFF    // Watchdog Timer Enable bits->WDT disabled; SWDTEN is ignored
#pragma config LPBOREN = OFF    // Low-power BOR enable bit->ULPBOR disabled
#pragma config BOREN = ON    // Brown-out Reset Enable bits->Brown-out Reset enabled, SBOREN bit ignored
#pragma config BORV = LOW    // Brown-out Reset Voltage selection bit->Brown-out voltage (Vbor) set to 2.45V
#pragma config PPS1WAY = ON    // PPSLOCK bit One-Way Set Enable bit->The PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle
#pragma config STVREN = ON    // Stack Overflow/Underflow Reset Enable bit->Stack Overflow or Underflow will cause a Reset
#pragma config DEBUG = OFF    // Debugger enable bit->Background debugger disabled

//CONFIG3
#pragma config WRT = OFF    // User NVM self-write protection bits->Write protection off
#pragma config LVP = ON    // Low Voltage Programming Enable bit->Low Voltage programming enabled. MCLR/VPP pin function is MCLR. MCLRE configuration bit is ignored.

//CONFIG4
#pragma config CP = OFF    // User NVM Program Memory Code Protection bit->User NVM code protection disabled
#pragma config CPD = OFF    // Data NVM Memory Code Protection bit->Data NVM code protection disabled

5.2.4.4.2 System Driver

This file contains the API prototype for the System Driver.

Module description

This file contains the API prototype for the System Driver.

Version: Driver Version 1.0.0
Functions
  • void SYSTEM_Initialize (void)

    Initializes the system module. This is called only once before calling other APIs.

Function Documentation

SYSTEM_Initialize()

void SYSTEM_Initialize (void )

Initializes the system module. This is called only once before calling other APIs.

Parameters:
None.
Returns:

None.

5.2.4.5 File Documentation

5.2.4.5.1 source/config_bits.c File Reference

This file contains the API Implementation for the Device Configuration Bits driver.

Detailed Description

This file contains the API Implementation for the Device Configuration Bits driver.

CONFIGURATION BITS Generated Driver Source File

Version: Driver Version 1.0.0

5.2.4.5.2 source/config_bits.h File Reference

#include "../system/clock.h"

Detailed Description

CONFIGURATION BITS Generated Driver Header File

5.2.4.5.3 source/system.c File Reference

This file contains the API implementation for the System Driver.

#include "../system.h"

Functions

  • void SYSTEM_Initialize (void)

    Initializes the system module. This is called only once before calling other APIs.

Detailed Description

This file contains the API implementation for the System Driver.

System Driver Source File

Version: Driver Version 1.0.0

5.2.4.5.4 source/system.h File Reference

#include <xc.h>
#include <stdint.h>
#include <stdbool.h>
#include "config_bits.h"
#include "../system/clock.h"
#include "../system/pins.h"
#include "../system/interrupt.h"

Functions

  • void SYSTEM_Initialize (void)

    Initializes the system module. This is called only once before calling other APIs.

Detailed Description

System Driver Header File