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文件,有上层调用代码时,不就定义了多次,的确会发生冲突。

相关推荐
TESmart碲视24 分钟前
USB一线连多屏?Display Link技术深度解析
stm32·单片机·嵌入式硬件·物联网·计算机外设·电脑·智能硬件
森焱森1 小时前
60 美元玩转 Li-Fi —— 开源 OpenVLC 平台入门(附 BeagleBone Black 驱动简单解析)
c语言·单片机·算法·架构·开源
__基本操作__1 小时前
stm32计时的两个方法
stm32·单片机·嵌入式硬件
千帐灯无此声1 小时前
Linux 测开:日志分析 + 定位 Bug
linux·c语言·c++·bug
BW.SU2 小时前
单片机显示Unicode字符介绍
单片机·嵌入式硬件·界面设计·字库·单片机驱动彩屏·ra8889·ra8876
ChuHsiang2 小时前
【C语言学习】实现游戏——三子棋
c语言
MARIN_shen3 小时前
Marin说PCB之Allegro高亮BOM器件技巧详解
单片机·嵌入式硬件·硬件工程·pcb工艺
权、狐妖4 小时前
STM32G473串口通信-USART/UART配置和清除串口寄存器状态的注意事项
stm32·单片机·嵌入式硬件
YTao_G4 小时前
STM32模块:023 WDG看门狗
stm32·单片机·嵌入式硬件