在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).
make2: *** dist/default/production/TCOM1.X.production.hex Error 255
make1: *** .build-conf Error 2
make: *** .build-impl Error 2
BUILD FAILED (exit value 2, total time: 10s)
要解决这个问题,可以按照以下步骤进行检查和修复:
-
检查配置字定义:确保在代码中没有重复定义配置字。配置字应只定义一次。如果项目中有多个源文件,检查每个源文件的配置字定义,确保它们不会互相冲突。
-
检查链接脚本:如果使用了自定义的链接脚本,检查链接脚本中的配置,确保配置区段不会发生重叠。
-
使用编译器提供的工具:一些编译器提供了工具来帮助检查和设置配置字,例如Microchip的MPLAB X IDE。使用这些工具可以帮助避免配置字冲突。
-
参考编译器和设备文档:查阅编译器和设备的文档,了解配置字的正确设置方法和可能的限制。
-
如何正确设置PIC24F系列微控制器的配置字:
#pragma config ICS = PGx1 // ICD Pin Placement Select bits (EMUC/EMUD share PGC1/PGD1) #pragma config JTAGEN = OFF
确保每个配置字只定义一次,并且没有冲突。
如果你已经检查了所有配置字定义并确保它们没有冲突,但问题仍然存在,请考虑以下步骤:
- 清理并重新构建项目。
- 更新编译工具链到最新版本。
- 如果使用IDE,检查IDE的项目设置,确保没有意外的配置。
解决方法:这些配置字要放在xxx.c文件内,不能放在xxx.h文件。其实若放在xxx.h文件,有上层调用代码时,不就定义了多次,的确会发生冲突。