MPLAB X IDE 环境中配置字的注意点

在MPLAB X IDE(芯片PIC24)中build生成程序,出现错误。

xxxxxxxxxxxxxxxxxxxxxxx
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
c:\program files (x86)\microchip\xc16\v1.31\bin\bin\..\bin/elf-ld.exe: Link Error: section .config_JTAGEN%26 [02abfe -> 02abff ] overlaps section . config_JTAGEN%23 [02abfe -> 02abff ]
c:\program files (x86)\microchip\xc16\v1.31\bin\bin\..\bin/elf-ld.exe: Link Error: section .config_IESO%27 [02abfc -> 02abfd ] overlaps section .config_IESO%24 [02abfc -> 02abfd ]
c:\program files (x86)\microchip\xc16\v1.31\bin\bin\..\bin/elf-ld.exe: Link Error: section .config_WPEND%28 [02abfa -> 02abfb ] overlaps section .config_WPEND%25 [02abfa -> 02abfb ]
c:\program files (x86)\microchip\xc16\v1.31\bin\bin\..\bin/elf-ld.exe: Link Error: section .config_JTAGEN%29 [02abfe -> 02abff ] overlaps section .config_JTAGEN%23 [02abfe -> 02abff ]
c:\program files (x86)\microchip\xc16\v1.31\bin\bin\..\bin/elf-ld.exe: Link Error: section .config_IESO%30 [02abfc -> 02abfd ] overlaps section .config_IESO%24 [02abfc -> 02abfd ]
c:\program files (x86)\microchip\xc16\v1.31\bin\bin\..\bin/elf-ld.exe: Link Error: section .config_WPEND%31 [02abfa -> 02abfb ] overlaps section .config_WPEND%25 [02abfa -> 02abfb ]
c:\program files (x86)\microchip\xc16\v1.31\bin\bin\..\bin/elf-ld.exe: Link terminated due to previous error(s).
make[2]: *** [dist/default/production/TCOM1.X.production.hex] Error 255
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 10s)

要解决这个问题,可以按照以下步骤进行检查和修复:

  1. 检查配置字定义:确保在代码中没有重复定义配置字。配置字应只定义一次。如果项目中有多个源文件,检查每个源文件的配置字定义,确保它们不会互相冲突。

  2. 检查链接脚本:如果使用了自定义的链接脚本,检查链接脚本中的配置,确保配置区段不会发生重叠。

  3. 使用编译器提供的工具:一些编译器提供了工具来帮助检查和设置配置字,例如Microchip的MPLAB X IDE。使用这些工具可以帮助避免配置字冲突。

  4. 参考编译器和设备文档:查阅编译器和设备的文档,了解配置字的正确设置方法和可能的限制。

  • 如何正确设置PIC24F系列微控制器的配置字:

    复制代码
    #pragma config ICS = PGx1               // ICD Pin Placement Select bits (EMUC/EMUD share PGC1/PGD1)
    #pragma config JTAGEN = OFF       

确保每个配置字只定义一次,并且没有冲突。

如果你已经检查了所有配置字定义并确保它们没有冲突,但问题仍然存在,请考虑以下步骤:

  1. 清理并重新构建项目。
  2. 更新编译工具链到最新版本。
  3. 如果使用IDE,检查IDE的项目设置,确保没有意外的配置。

解决方法:这些配置字要放在xxx.c文件内,不能放在xxx.h文件。其实若放在xxx.h文件,有上层调用代码时,不就定义了多次,的确会发生冲突。

相关推荐
晶振厂家-晶发电子2 天前
晶振在5G时代的角色:高精度时钟的核心支撑
单片机·嵌入式硬件·5g·晶振·电子元器件·晶振知识
F137298015572 天前
WD5030A 芯片,12V降5V,输出电流12A,电路设计
stm32·单片机·嵌入式硬件·汽车·51单片机
小莞尔2 天前
【51单片机】【protues仿真】基于51单片机的篮球计时计分器系统
c语言·stm32·单片机·嵌入式硬件·51单片机
三佛科技-187366133972 天前
分享机械键盘MCU解决方案
单片机·嵌入式硬件·计算机外设
李永奉2 天前
51单片机-使用IIC通信协议实现EEPROM模块教程
单片机·嵌入式硬件·51单片机
小莞尔2 天前
【51单片机】【protues仿真】 基于51单片机八路抢答器系统
c语言·开发语言·单片机·嵌入式硬件·51单片机
liujing102329292 天前
Day03_刷题niuke20250915
c语言
bing_feilong2 天前
STM32精准控制水流
单片机·嵌入式硬件
第七序章3 天前
【C++STL】list的详细用法和底层实现
c语言·c++·自然语言处理·list
l1t3 天前
利用DeepSeek实现服务器客户端模式的DuckDB原型
服务器·c语言·数据库·人工智能·postgresql·协议·duckdb