Record how to configure the configuration bits in MPLAB XIDE

Publisher:转眼人老Latest update time:2020-08-14 Source: eefocusKeywords:MPLAB Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Based on MPLAB X IDE Configuration Bits

The most important configuration options in the configuration word are:

Watchdog configuration such as: WDTE<1;0>; usually choose to turn off the watchdog

MCLRE reset pin configuration such as: MCLRE; generally choose the reset pin as I/O

Oscillator selection: For example: FOSC<2:0>; configure according to the actual situation, I usually choose to use the INTOSC internal oscillator.

Because if these three are not configured properly, the program will not run at all. For other configurations, please refer to the data manual.

MPLAB X IDE and MPLAB IDE 8 are different.

MPLAB IDE 8 allows you to select configuration bits in the interface. Configuration options do not need to be written in the code.

MPLAB X IDE must be configured in code if it is to be configured.

Example introduction:

 1. Open MPLAB X IDE and click Window->PIC Memory Views->Configuration bits in the menu bar.

 2 Change the option in each configuration in the Configuration Bits that appears. The red ones are the configuration options we have changed.

 

3 After configuration is completed, click Genarate Source Code to Output to generate the configuration source code.


Copy __CONFIG(FOSC_INTOSC & WDTE_OFF & PWRTE_ON & MCLRE_OFF & CP_ON & CPD_ON & BOREN_ON & CLKOUTEN_OFF & IESO_ON & FCMEN_ON);
__CONFIG(WRT_OFF & PLLEN_OFF & STVREN_ON & BORV_LO & LVP_OFF); into the source code. The header file #include must be included in the source code.


Here I point out an error in MPLAB X IDEv1.10. The compiler does not recognize the BORV_LO configuration in the configuration. This may be due to the lack of coordination between the programmer who wrote the software and the programmer who wrote the header file:

The compiler only recognizes header files. In the header file pic16f1823.h, BORV_LO is not defined but it is defined as BORV_19. BORV_HI is defined as BORV_25. In short, just change BORV_LO to BORV_19.

The following is an explanation of the configuration bits of 16F877A as requested by netizens:

CP: Program Area Protection Setting this bit to 1 will turn it on. (This bit must be turned on to prevent the program from being read)

DEBUG: Enable debugging. If not enabled, RB6 and RB7 pins will be used as normal I/O ports (depending on requirements).

WRT1: WRT0: Write protection bit. Prevent the program area from being accidentally written. (Generally recommended to enable)

CPD: EEPROM protection, (this bit must be turned on to prevent the data in the EEPROM from being read)

LVP: Low voltage programming enable bit. If low voltage programming is not used, RB3 will be used as a normal I/O. MCLR must be used for programming. (As required)

BOREN: Power-off detection. The function of power-off detection is to stop the microcontroller from working in time when it finds that the voltage is insufficient. This prevents some unexpected operations from happening, such as data loss in EEPROM or FLASH (this must generally be turned on to prevent code loss)

PWRTEN: Power-on delay. After it is turned on, the MCU will delay 72MS to start working. Ensure that the MCU will start working after the circuit is stable after power-on. It is not required that the MCU work immediately after power-on. It is recommended to turn this bit on. (Recommended to turn it on)

WDTEN: Watchdog. This bit depends on your needs. After it is turned on, the program must keep feeding the watchdog. If it is not fed well, the program will reset. (According to needs)

FOSC1: FOSC0: Oscillator selection bits. If you want a high speed, choose HS. If you want a medium speed, choose XT. If you want a low speed and low power consumption, choose LP. If you want a cheap oscillator that does not require high precision, use RC. (Select according to your needs)

  20MHz~4MHz (including 4MHz) quartz crystal configuration HS.

  4MHz (including 4MHz) ~ 200KHz (including 200KHz) quartz crystal configuration XT.

  200KHz (including 200KHz) ~ 32KHz quartz crystal configuration LP.

RC is a resistor plus a capacitor. You can make a cheap but low-precision oscillator.


Keywords:MPLAB Reference address:Record how to configure the configuration bits in MPLAB XIDE

Previous article:MPLAB X IDE v5.30 offline installation MCC method
Next article:HEX file format analysis - applicable to MPLAB

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号