chenjunt 发表于 2022-6-11 13:39

总是在__config这行提示错误

本帖最后由 pzsh 于 2022-6-25 15:58 编辑

想先简单控制I/O口,找了网上的例程,把代码复制到MPLAB里,编译就出错,几个简单的代码,也没发现有写错的地方,求助各位解惑,在此谢过!
#include <xc.h>
#include <pic.h>

__config(0x00a);
void main(void)
{
    while(1)
    {
      TRIS = ~0x3f;
      GP1 = 1;
    }
}

就这么几句,总是在__config这行提示错误,也没发现什么原因?

chenjunt 发表于 2022-6-11 13:41


chuxh 发表于 2022-6-11 13:45

你这个0x00a正确吗?

chenjunt 发表于 2022-6-11 13:47

正确,用0x0A也是一样错误。

chenjunt 发表于 2022-6-11 13:49

大小写,全角半角进行检查,你不要复制,新建一个试试。

chenjunt 发表于 2022-6-11 13:51


重新用英文模式写了一遍,也提示一样的错误。

chuxh 发表于 2022-6-11 13:56

__config(0x00a);
把它换成大写的就可以了:
__CONFIG(0x00a);

chenjunt 发表于 2022-6-11 13:58

也是提示一样的错误!

chenjunt 发表于 2022-6-11 14:00


dingy 发表于 2022-6-11 14:03

你这个是IDE的标记问题, 只要编译没错就不用去理它

jiajs 发表于 2022-6-11 14:04

配置为配置了吗

juventus9554 发表于 2022-6-11 14:06

试了一下,你这个是__config这句有错,应该是设置配置位的,你有IDE里configbits设置应该就可以了

chenjunt 发表于 2022-6-11 14:08

就是编译出错

chenjunt 发表于 2022-6-11 14:12

这个就是设置配置位的,但是这样写怎么不对呢?

pengf 发表于 2022-6-11 14:15

#pragma config CONFIG = 0x00A; 你这样写试试

dengdc 发表于 2022-6-11 14:18

你这是以前编译器的代码吧, 现在xc8 不支持这个,看以下pic.h里的代码.
//
// Legacy Programming Macro Functions
//
#ifdef _XC8_MODE_
#define _NO_CONFIG_SUP(f)      __asm("GLOBAL nosup@@$_$_" ___mkstr(f) "\nnosup@@$_$_" ___mkstr(f) " SET 0")
#define __CONFIG(x)                        _NO_CONFIG_SUP(CONFIG)                              
#define __IDLOC(w)                        _NO_CONFIG_SUP(IDLOC)                              
#define __IDLOC7(a,b,c,d)      _NO_CONFIG_SUP(IDLOC7)                              
#define __PROG_CONFIG(a,x)      _NO_CONFIG_SUP(PROG_CONFIG)               

我试着编译你这个代码,没出错,但是有警告:
::: warning: (1374) the compiler feature "__CONFIG" is no longer supported; consult the documentation for more details

wyjie 发表于 2022-6-11 14:20


你编译器用的什么版本的?

我用XC8 v2.05, 改成大写的之后就可以顺利编译通过了...
更多操作

chenjunt 发表于 2022-6-11 14:52


我在网上下载的最新版
#pragma config OSC = IntRC
用这种方式写各个配置项就没有问题了!谢谢各位!

zhanghqi 发表于 2022-6-11 14:54

你那个是旧版写法

zwll 发表于 2022-6-11 14:57

感觉,PIC的软件不能统一,会分很多型号专用的。
页: [1] 2
查看完整版本: 总是在__config这行提示错误