5.2.3 4-byte Config Bits Registers

Configuration Registers with 4 Bytes

5.2.3.1 Introduction

The Configuration settings allow the user to select the oscillators, reset sources and memory protection 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.3.2 Supported Device Families

PIC16(L)F152xx

5.2.3.3 Required Header Files:


#include "mcc_generated_files/config_bits.h"

5.2.3.4 Sample Code

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     // External Oscillator Mode Selection bits->EC (external clock) 16 MHz and above
#pragma config RSTOSC = EXTOSC     // 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 function on RA6
#pragma config VDDAR = HI     // VDD Range Analog Calibration Selection bit->Internal analog systems are calibrated for operation between VDD = 2.3V - 5.5V

//CONFIG2
#pragma config MCLRE = EXTMCLR     // Master Clear Enable bit->If LVP = 0, MCLR pin is MCLR; If LVP = 1, RE3 pin function is MCLR
#pragma config PWRTS = PWRT_OFF     // Power-up Timer Selection bits->PWRT is disabled
#pragma config WDTE = OFF     // WDT Operating Mode bits->WDT disabled; SEN is ignored
#pragma config BOREN = ON     // Brown-out Reset Enable bits->Brown-out Reset Enabled, SBOREN bit is ignored
#pragma config BORV = LO     // Brown-out Reset Voltage Selection bit->Brown-out Reset Voltage (VBOR) set to 1.9V
#pragma config PPS1WAY = ON     // PPSLOCKED One-Way Set Enable bit->The PPSLOCKED bit can be set once after an unlocking sequence is executed; once PPSLOCKED is set, all future changes to PPS registers are prevented
#pragma config STVREN = ON     // Stack Overflow/Underflow Reset Enable bit->Stack Overflow or Underflow will cause a reset

//CONFIG4
#pragma config BBSIZE = BB512     // Boot Block Size Selection bits->512 words boot block size
#pragma config BBEN = OFF     // Boot Block Enable bit->Boot Block is disabled
#pragma config SAFEN = OFF     // SAF Enable bit->SAF is disabled
#pragma config WRTAPP = OFF     // Application Block Write Protection bit->Application Block is not write-protected
#pragma config WRTB = OFF     // Boot Block Write Protection bit->Boot Block is not write-protected
#pragma config WRTC = OFF     // Configuration Registers Write Protection bit->Configuration Registers are not write-protected
#pragma config WRTSAF = OFF     // Storage Area Flash (SAF) Write Protection bit->SAF is not write-protected
#pragma config LVP = ON     // Low Voltage Programming Enable bit->Low Voltage programming enabled. MCLR/Vpp pin function is MCLR. MCLRE Configuration bit is ignored.

//CONFIG5
#pragma config CP = OFF     // User Program Flash Memory Code Protection bit->User Program Flash Memory code protection is disabled

5.2.3.5 Module Documentation

5.2.3.5.1 CONFIGBITS Driver

This file contains the API prototypes and other datatypes for the Configuration Bits driver.

Module description

This file contains the API prototypes and other datatypes for the Configuration Bits driver.

Version: Driver Version 2.0.2 Package Version 4.1.2

5.2.3.5.2 System Driver

This file contains the API prototypes and other datatypes for the System Driver.

Module description

This file contains the API prototypes and other datatypes for the System Driver.

Version: Driver Version 2.0.3 Package Version 4.1.2
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.3.6 File Documentation

5.2.3.6.1 source/source_files/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 2.0.2 Package Version 4.1.2

5.2.3.6.2 source/source_files/config_bits.h File Reference

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

Detailed Description

CONFIGURATION BITS Generated Driver Header File

5.2.3.6.3 source/source_files/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 2.0.3 Package Version 4.1.2

5.2.3.6.4 source/source_files/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