c - 在 MPLAB X ide 上编译 c 文件时出错

标签 c gcc makefile microchip mplab

尝试在 Windows 上使用 MPLAB X 进行编译时出现以下错误。


newmain.c:40:9: error: unknown configuration setting: 'JTAGEN'

newmain.c:61:2: error: 'LATA' undeclared (first use in this function)

newmain.c:62:2: error: 'TRISA' undeclared (first use in this function)

newmain.c:61:2: error: 'LATA' undeclared (first use in this function)

我在 2 台不同的机器上(在 Windows 8.1 和 Vista 上)试过这个,但它们都给了我同样的错误。

似乎 xc.h 文件已经包含在项目中,因为我可以打开该文件。我还用谷歌搜索了这个问题,但没有解决方案。

如果你能给我一个可能的解决方法,非常感谢。

我还附上了描述该项目的项目属性的照片。

enter image description here

错误的完整描述如下:

 - CLEAN SUCCESSFUL (total time: 52ms) make -f
   nbproject/Makefile-default.mk SUBPROJECTS= .build-conf make[1]:
   Entering directory 'Z:/Personal Data/MPLABXProjects/Lab01.X' make -f
   nbproject/Makefile-default.mk
   dist/default/production/Lab01.X.production.hex make[2]: Entering
   directory 'Z:/Personal Data/MPLABXProjects/Lab01.X' "Z:\Program Files
   (x86)\Microchip\xc32\v1.40\bin\xc32-gcc.exe" -g -x c -c
   -mprocessor=32MX340F512H -MMD -MF build/default/production/newmain.o.d -o
   build/default/production/newmain.o newmain.c newmain.c:40:9: error:
   unknown configuration setting: 'JTAGEN' #pragma config JTAGEN = OFF
   // JTAG Enable OFF (only use for '250)
   nbproject/Makefile-default.mk:105: recipe for target
   'build/default/production/newmain.o' failed ^ newmain.c: In function
   'main': make[2]: Leaving directory 'Z:/Personal
   Data/MPLABXProjects/Lab01.X' newmain.c:61:2: error: 'LATA' undeclared
   (first use in this function) nbproject/Makefile-default.mk:78: recipe
   for target '.build-conf' failed LATA = 0; // Set value of PORT A
   output to 0. ^ make[1]: Leaving directory 'Z:/Personal
   Data/MPLABXProjects/Lab01.X' nbproject/Makefile-impl.mk:39: recipe
   for target '.build-impl' failed newmain.c:61:2: note: each undeclared
   identifier is reported only once for each function it appears in
   newmain.c:62:2: error: 'TRISA' undeclared (first use in this
   function) TRISA = 0; // Set all pins on PORT A to output ^ make[2]:
   *** [build/default/production/newmain.o] Error 1 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 BUILD FAILED
   (exit value 2, total time: 203ms)

来源是

#include <xc.h>

#pragma config FWDTEN = OFF, JTAGEN = OFF

void delay(void);

unsigned int ctr = 0;
unsigned int delayVal = 2048;

int main(void)
{
    LATA = 0;
    TRISA = 0xFF00;

    while(1)
    {
        LATA = 0x0055;
        delay();

        LATA = 0x00AA;
        delay();

        ctr++;
    }
}

void delay(void)
{
    unsigned int i,j;

    for (i = 0; i < delayVal; i++)
    {
        for (j = 0; j < 20; j++);
    }
}

最佳答案

您收到的错误表明编译器没有看到任何库来引用这些寄存器。而是将它们视为常规变量。

您应该包括您正在使用的处理器的特定头文件,并检查其中的寄存器结构,以便更好地理解您的问题。

关于c - 在 MPLAB X ide 上编译 c 文件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34703042/

相关文章:

c++ - std::strcpy 未在此范围内声明 DESPITE #include <cstring>

makefile - 与 googletest 链接时 undefined reference

bash - bash 中的 $(shell) 引用

c - 递归增量器

c - Arduino程序中LED无法闪烁3次

python - 在Python模块中调用C头文件函数

makefile - Make 目标依赖于二进制文件,它可能存在也可能不存在于 $PATH

c - 使用一个命令释放所有 malloc() 创建的指针?

c++ - 外部结构前向声明

c++ - C++ 中标识符名称的长度是否有限制?