CONFIG is also called fuse bit. You can configure the internal functions of the microcontroller by configuring the fuse bit, such as crystal clock, watchdog, JTAG, power-off detection and code protection. If you don't understand these settings, it is recommended to copy and paste them directly.
In PIC microcontrollers, we can set fuse bits by adding CONFIG code to the code, or we can configure them through the interface in the MPLAB IDE integrated development environment.
Interface configuration method:
Click Configure>Select Device to select the corresponding device. Here we select PIC24FJ64GB004, as shown in Figure 1 and Figure 2:
figure 1
figure 2
After selecting the device, click Configure>Configuration Bits to enter the interface of Figure 3 and cancel Configuration Bits set in code. Then you can configure CONFIG through the interface, as shown in Figure 3.
image 3
From Figure 3, we can also see that the CONFIG of PIC24FJ64GB004 is stored at the address of 0xABF8 0xABFE, which also corresponds to the CONFIG address in the GLD file. The Value corresponding to each setting option is also different. As for the specific meaning of each setting option in the figure, please refer to the configuration in the code below.
Configuration method in code:
If you want to configure in code, you need to check Configration Bits set in code in the interface of Figure 3, and then add CONFIG code in the code, as follows:
#include Then we find the p24fxxxx.h file in the C30 compiler, the file location: C:Program FilesMicrochipMPLAB C30supportPIC24Fh, and find the header file p24FJ64GB004.h of the specific device through p24fxxxx.h. This header file describes in detail the meaning of each CONFIG configuration and the specific Value value. 截取其中一段注释与代码如下: From the comments, we can see that WDTPS_PS1 is about the watchdog clock pre-scaling setting, and FWDTEN is about whether the watchdog clock is started. By comparing the CONFIG code, we can find that the watchdog clock is set to undivided and not started.
CONFIG1(WDTPS_PS1 & FWPSA_PR32 & WINDIS_OFF & FWDTEN_OFF & ICS_PGx1 & GWRP_OFF & GCP_OFF & JTAGEN_OFF)
_CONFIG2(POSCMOD_HS & I2C1SEL_PRI & IOL1WAY_OFF & OSCIOFNC_ON & FCKSM_CSDCMD & FNOSC_PRIPLL & PLL96MHZ_ON & PLLDIV_DIV2 & IESO_ON)
_CONFIG3(WPFP_WPFP0 & SOSCSEL_SOSC & WUTSEL_LEG & WPDIS_WPDIS & WPCFG_WPCFGDIS & WPEND_WPENDMEM)
_CONFIG4(DSWDTPS_DSWDTPS3 & DSWDTOSC_LPRC & RTCOSC_SOSC & DSBOREN_OFF & DSWDTEN_OFF)
/*
** Only one invocation of CONFIG1 should appear in a project,
** at the top of a C source file (outside of any function).
**
** The following constants can be used to set CONFIG1.
** Multiple options may be combined, as shown:
**
** _CONFIG1( OPT1_ON & OPT2_OFF & OPT3_PLL )
**
** Watchdog Timer Postscaler:
** WDTPS_PS1 1:1
** WDTPS_PS2 1:2
** WDTPS_PS4 1:4
......
......
** Watchdog Timer:
** FWDTEN_OFF Watchdog Timer is disabled
** FWDTEN_ON Watchdog Timer is enabled
......
......
#define WDTPS_PS1 0x7FF0
#define WDTPS_PS2 0x7FF1
#define WDTPS_PS4 0x7FF2
......
......
#define FWDTEN_OFF 0x7F7F
#define FWDTEN_ON 0x7FFF
Previous article:Summary of MCU key learning
Next article:PIC microcontroller i2c program
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- DS18B20 STM32G474 driver
- Design of LED emergency lighting controller based on MSP430
- Pay attention when drawing and punching PCB!!
- Introduction to Multithreaded Programming in Embedded Systems
- Things about IoT and Bluetooth 4.2
- EEWORLD University ---- Machine Learning Basics: Case Studies (University of Washington)
- Function and usage of J-Link script file
- I would like to ask about the information about the electronic engineer certificate
- Microwave Filters for Communication Systems - Fundamentals, Design and Applications
- Read the good book "Self-study Handbook for Electronic Engineers" - Content Preview