CONGFIG description of PIC microcontroller in ZC-ADK

Publisher:chunyingLatest update time:2019-11-27 Source: eefocusKeywords:ZC-ADK Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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:

1.jpg

figure 1

2.jpg

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.

3.jpg

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 
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)

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.

截取其中一段注释与代码如下:
/*
** 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

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.

Keywords:ZC-ADK Reference address:CONGFIG description of PIC microcontroller in ZC-ADK

Previous article:Summary of MCU key learning
Next article:PIC microcontroller i2c program

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号