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

相关推荐
不能跑的代码不是好代码3 小时前
STM32窗口看门狗(WWDG)知识点及标准库使用指南
stm32·单片机·嵌入式硬件
bingquan33333 小时前
在 Ghidra 中分析STM32裸机固件
stm32·单片机·嵌入式硬件
羽获飞3 小时前
从零开始学嵌入式之STM32——11.STM32---USART串行通讯
stm32·单片机·嵌入式硬件
宵时待雨4 小时前
STM32笔记归纳9:定时器
笔记·stm32·单片机·嵌入式硬件
逐步前行4 小时前
STM32_新建工程(寄存器版)
stm32·单片机·嵌入式硬件
bai5459365 小时前
STM32 CubeIDE 通过PWM占空比控制舵机角度
stm32·单片机·嵌入式硬件
2401_858936886 小时前
【Linux C 编程】标准 IO 详解与实战:从基础接口到文件操作实战
linux·c语言
松涛和鸣7 小时前
72、IMX6ULL驱动实战:设备树(DTS/DTB)+ GPIO子系统+Platform总线
linux·服务器·arm开发·数据库·单片机
上海合宙LuatOS7 小时前
LuatOS核心库API——【audio 】
java·网络·单片机·嵌入式硬件·物联网·音视频·硬件工程
Hhh __灏8 小时前
stm32的SRAM内存不足如何分析和优化?堆栈空间如何优化?
单片机