5.3.2 9-byte Config Bits Registers

5.3.2.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.3.2.2 Supported Device Families

PIC18F-K42

5.3.2.3 Required Header Files:

#include "mcc_generated_files/system/config_bits.h"

5.3.2.4 Module Documentation

5.3.2.4.1 CONFIGBITS Driver

This is the generated header file for the Configuration bits driver.

Module description

This is the generated header file 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.

//CONFIG1L
#pragma config FEXTOSC = ECH     // External Oscillator Selection->EC (external clock) above 8 MHz; PFM set to high power
#pragma config RSTOSC = EXTOSC     // Reset Oscillator Selection->EXTOSC operating per FEXTOSC bits (device manufacturing default)

//CONFIG1H
#pragma config CLKOUTEN = OFF     // Clock out Enable bit->CLKOUT function is disabled
#pragma config CSWEN = ON     // Clock Switch Enable bit->Writing to NOSC and NDIV is allowed
#pragma config FCMEN = ON     // Fail-Safe Clock Monitor Enable bit->Fail-Safe Clock Monitor enabled
#pragma config PR1WAY = ON     // PRLOCKED One-Way Set Enable bit->PRLOCK bit can be cleared and set only once

//CONFIG2L
#pragma config MCLRE = EXTMCLR     // MCLR Enable bit->If LVP = 0, MCLR pin is MCLR; If LVP = 1, RE3 pin function is MCLR 
#pragma config LPBOREN = OFF     // Low Power BOR Enable bit->ULPBOR disabled
#pragma config BOREN = SBORDIS     // Brown-out Reset Enable bits->Brown-out Reset enabled , SBOREN bit is ignored
#pragma config PWRTS = PWRT_OFF     // Power-up timer selection bits->PWRT is disabled
#pragma config MVECEN = OFF     // Multi-vector enable bit->Interrupt contoller does not use vector table to prioritze interrupts
#pragma config IVT1WAY = ON     // IVTLOCK bit One-way set enable bit->IVTLOCK bit can be cleared and set only once

//CONFIG2H
#pragma config BORV = VBOR_2P45     // Brown-out Reset Voltage Selection bits->Brown-out Reset Voltage (VBOR) set to 2.45V
#pragma config ZCD = OFF     // ZCD Disable bit->ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON
#pragma config PPS1WAY = ON     // PPSLOCK bit One-Way Set Enable bit->PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle
#pragma config STVREN = ON     // Stack Full/Underflow Reset Enable bit->Stack full/underflow will cause Reset
#pragma config DEBUG = OFF     // Debugger Enable bit->Background debugger disabled
#pragma config XINST = OFF     // Extended Instruction Set Enable bit->Extended Instruction Set and Indexed Addressing Mode disabled

//CONFIG3L
#pragma config WDTCPS = WDTCPS_31     // WDT Period selection bits->Divider ratio 1:65536; software control of WDTPS
#pragma config WDTE = OFF     // WDT operating mode->WDT Disabled; SWDTEN is ignored

//CONFIG3H
#pragma config WDTCWS = WDTCWS_7     // WDT Window Select bits->window always open (100%); software control; keyed access not required
#pragma config WDTCCS = SC     // WDT input clock selector->Software Control

//CONFIG4L
#pragma config BBSIZE = BBSIZE_512     // Boot Block Size selection bits->Boot Block size is 512 words
#pragma config BBEN = OFF     // Boot Block enable bit->Boot block disabled
#pragma config SAFEN = OFF     // Storage Area Flash enable bit->SAF disabled
#pragma config WRTAPP = OFF     // Application Block write protection bit->Application Block not write protected

//CONFIG4H
#pragma config WRTC = OFF     // Configuration Register Write Protection bit->Configuration registers not write-protected
#pragma config WRTB = OFF     // Boot Block Write Protection bit->Boot Block not write-protected
#pragma config WRTD = OFF     // Data EEPROM Write Protection bit->Data EEPROM 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
#pragma config WRTSAF = OFF     // SAF Write protection bit->SAF not Write Protected

//CONFIG5L
#pragma config CP = OFF     // PFM and Data EEPROM Code Protection bit->PFM and Data EEPROM code protection disabled

5.3.2.4.2 System Driver

This is the generated header file for the System driver.

Module description

This is the generated header file for the System driver.

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

    Initializes the Peripheral Module Disable (PMD) module.

  • void SYSTEM_Initialize (void)

    Initializes the system module. This routine is called only once during system initialization, before calling other APIs.

Function Documentation

PMD_Initialize()

void PMD_Initialize (void )

Initializes the Peripheral Module Disable (PMD) module.

Parameters:
None.
Returns:

None.

SYSTEM_Initialize()

void SYSTEM_Initialize (void )

Initializes the system module. This routine is called only once during system initialization, before calling other APIs.

Parameters:
None.
Returns:

None.

5.3.2.5 File Documentation

5.3.2.5.1 source/source-files/config_bits.c File Reference

This is the generated Device Configuration bits file.

Detailed Description

This is the generated Device Configuration bits file.

Configuration Bits Generated Driver Source File

Version: Driver Version 1.0.0

5.3.2.5.2 source/source-files/config_bits.h File Reference

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

Detailed Description

Configuration Bits Generated Driver Header File

5.3.2.5.3 source/source-files/system.c File Reference

This file contains the API implementation for the System driver.

#include "../system.h"

Functions

  • void PMD_Initialize (void)

    Initializes the Peripheral Module Disable (PMD) module.

  • void SYSTEM_Initialize (void)

    Initializes the system module. This routine is called only once during system initialization, 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.3.2.5.4 source/source-files/system.h File Reference

#include <xc.h>
#include <stdint.h>
#include <stdbool.h>
#include <conio.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 routine is called only once during system initialization, before calling other APIs.

Detailed Description

System Driver Header File