搜索
bottom↓
回复: 11

MPLAB X ide config位的问题

[复制链接]

出0入0汤圆

发表于 2015-7-16 22:22:50 | 显示全部楼层 |阅读模式
PIC18单片机。

第一次用MPLAB X IDE  ,想对配置位进行设置,找到了设置界面,也输出生成源代码了。把源代码复制出来拷贝到.C文件里。编译报错:

:: warning: (1273) Omniscient Code Generation not available in Free mode
mcc_generated_files/Config.c:19: error: (1389) attempt to reprogram configuration setting "PWRTEN" with ON (is OFF)
mcc_generated_files/Config.c:20: error: (1389) attempt to reprogram configuration setting "BOREN" with ON (is SBORDIS)
mcc_generated_files/Config.c:21: error: (1389) attempt to reprogram configuration setting "BORV" with 250 (is 190)
mcc_generated_files/Config.c:24: error: (1389) attempt to reprogram configuration setting "WDTEN" with ON (is OFF)
mcc_generated_files/Config.c:25: error: (1389) attempt to reprogram configuration setting "WDTPS" with 256 (is 32768)
mcc_generated_files/Config.c:29: error: (1389) attempt to reprogram configuration setting "PBADEN" with OFF (is ON)
(908) exit status = 1
nbproject/Makefile-default.mk:375: recipe for target 'dist/default/production/dljck20.X.production.hex' failed
make[2]: Leaving directory 'D:/dljck20/dljck20.X'
nbproject/Makefile-default.mk:78: recipe for target '.build-conf' failed
make[1]: Leaving directory 'D:/dljck20/dljck20.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [dist/default/production/dljck20.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

编译已失败 (退出值2, 总时间: 3s)

如果不拷贝到C文件里,不报错。但是不知道设置的配置位是否起作用了,是否设置成功了。再次打开配置界面,还是以前的值,好像没有设置成功的样子。

请问:输出生成的源代码是怎样利用的?  设置过配置位后,再次打开设置对话框,怎么不记忆,还是默认值? 生成的源代码复制到C文件里后,编译报错怎么处理?(我知道报错是因为c文件里设置的和工程里配置的不一样,冲突了,但是解决呢?按道理,配置过后会生效记忆的啊。)

出0入0汤圆

 楼主| 发表于 2015-7-17 11:02:40 | 显示全部楼层
顶起来。别沉了。

出0入0汤圆

发表于 2015-7-17 11:29:06 | 显示全部楼层
没试过放在在.c文件里...

都是单独建一个 “config.h”的头文件,把全部的配置语句原样粘贴进去,然后 include 进main.c文件里。。。

------------------------------------
之前microchip 官方社区里看来的方法。。。


出0入0汤圆

 楼主| 发表于 2015-7-17 12:13:04 | 显示全部楼层
M1379 发表于 2015-7-17 11:29
没试过放在在.c文件里...

都是单独建一个 “config.h”的头文件,把全部的配置语句原样粘贴进去,然后 inc ...

放在config。h里了,还是不行:
#include "config.h"
#include "mcc_generated_files/mcc.h"
#include "main.h"

:: warning: (1273) Omniscient Code Generation not available in Free mode
INC\config.h:14: error: (1389) attempt to reprogram configuration setting "PRICLKEN" with ON (is OFF)
INC\config.h:19: error: (1389) attempt to reprogram configuration setting "PWRTEN" with ON (is OFF)
INC\config.h:20: error: (1389) attempt to reprogram configuration setting "BOREN" with ON (is SBORDIS)
INC\config.h:21: error: (1389) attempt to reprogram configuration setting "BORV" with 250 (is 190)
INC\config.h:24: error: (1389) attempt to reprogram configuration setting "WDTEN" with ON (is OFF)
INC\config.h:25: error: (1389) attempt to reprogram configuration setting "WDTPS" with 256 (is 32768)
INC\config.h:29: error: (1389) attempt to reprogram configuration setting "PBADEN" with OFF (is ON)
INC\config.h:38: error: (1389) attempt to reprogram configuration setting "LVP" with ON (is OFF)
INC\config.h:58: error: (1389) attempt to reprogram configuration setting "WRTC" with ON (is OFF)
(908) exit status = 1
nbproject/Makefile-default.mk:359: recipe for target 'dist/default/production/dljck20.X.production.hex' failed
make[2]: Leaving directory 'D:/dljck20/dljck20.X'
nbproject/Makefile-default.mk:78: recipe for target '.build-conf' failed
make[1]: Leaving directory 'D:/dljck20/dljck20.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [dist/default/production/dljck20.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

编译已失败 (退出值2, 总时间: 3s)


是否是。h里设置了,编译器里又有自己的设置,然后冲突了? 能否把编译器里的设置禁用?

出0入0汤圆

发表于 2015-7-17 13:58:14 来自手机 | 显示全部楼层
找到configuration bits菜单,里面可以配,配完可以生成宏,贴到c里就可以了。那个菜单不同版本位置不同,可能在run下面,可能在windows的pic memory views里。

出0入0汤圆

 楼主| 发表于 2015-7-17 14:03:36 | 显示全部楼层
TANK99 发表于 2015-7-17 13:58
找到configuration bits菜单,里面可以配,配完可以生成宏,贴到c里就可以了。那个菜单不同版本位置不同, ...

生成后贴到c里编译报错啊

出0入0汤圆

发表于 2015-7-16 22:22:51 | 显示全部楼层
直接从报错结果看,是不是你实际进行了两次 configuration bits 的配置 ?

比如,在你的 config.h 文件里有这样连着的语句

#pragma config PWRTEN = ON

#pragma config PWRTEN = OFF  //这两句不一定连续,也可能是在你的配置文件里隔着若干行出现了.

----------------------------------------------------------


以上只是猜测,是把的你IDE报错信息粘贴到google里查到的,具体链接我没权限发,你自己搜搜看。。。

出0入0汤圆

发表于 2015-7-17 16:45:46 | 显示全部楼层
我的没有报错  估计是你的C文件有些语法错误

出0入0汤圆

 楼主| 发表于 2015-7-17 18:02:37 | 显示全部楼层
M1379 发表于 2015-7-17 15:15
直接从报错结果看,是不是你实际进行了两次 configuration bits 的配置 ?

比如,在你的 config.h 文件里有 ...

应该是有多次的定义,但不是在。h里多次定义了。而是:。h里定义了一次,然后mplab x ide 这个开发环境有个默认的配置,他们就重复了。

现在的问题是,只用开发环境的配置是不是就够了,不用再复制到h或c文件里了?

这个好像是不行的,因为网上很多人都说要复制,而且它自己生成的代码也说要添加上工程里。

另外,每次进配置位设置界面配置都是默认值,刚刚配置过的,并没有体现出来。

添加到c文件里和h文件里应该是一样的。我两种方式都试了,报一样的错。

我猜测是不是在工程文件里添加了,就要屏蔽编译环境中默认的。不知道怎么屏蔽。

另外,我觉得mplab x ide 这个软件很不好用,它报错报的乱七八糟。是A错误,它报B错误。自己定义的结构体变量它有的认识,有的不认识,出报警,但是能编译和正常工作。

错误类型复制到网上查了,查不到同样的问题,所以,这个问题可能是个很RZ的问题,就我这边出现了。但是又不知道怎么错的。

出0入0汤圆

 楼主| 发表于 2015-7-17 18:04:43 | 显示全部楼层
hongjie0216 发表于 2015-7-17 16:45
我的没有报错  估计是你的C文件有些语法错误

应该不是。

内容全是编译器自动生成的代码,我全部复制的。

不复制进去,编译能通过。说明错误在加入了复制进去的内容后产生的。

我怀疑是有别的地方也定义了配置位。两个冲突了。

出0入0汤圆

 楼主| 发表于 2015-7-17 18:21:15 | 显示全部楼层
M1379 发表于 2015-7-17 15:15
直接从报错结果看,是不是你实际进行了两次 configuration bits 的配置 ?

比如,在你的 config.h 文件里有 ...

用百度没有查到同样的错误。

用谷歌查到了两条类似的错误。

http://www.microchip.com/forums/m788338.aspx



Hi,

I was running a project and compiling it fine for a fews days when all of a sudden I started getting very strange error:

Error [1389] attempt to reprogram configuration WDTEN "OFF" with SWON (is OFF)

I cannot seem to solve this problem which is illogical for my code. I have tried removing the #pragma config section entirely, but alas keesp on giving this error. Config bits are set in code, but that doesn't seem to make any difference.

Help would be appreciated.
post edited by art tech - Friday, May 02, 2014 8:20 AM

//-----------------------------------
Help
1) do not Hijack an old thread, start a new one.
2) what Tools MPLab ? Version? Compiler? Version?
3) the full error message.
4) The Code at the Line indicated in the message ( Plus some before and after)
5) are you #including a C File? (Don't)
6) is it in a header? ( Is it included more than once)

The Error says
#pragma config WDTEN = OFF
is followed by:
#pragma config WDTEN = SWON

This mean anything to you?



是老外的论坛。没有最终的结果,外国同行寻求帮助无果后怀疑是他的工程坏掉了,重建了工程。


My compiler error does indeed seem to have been a corrupt project and is working again in a freshly opened (and painfully rebuilt) project.

出0入0汤圆

 楼主| 发表于 2015-7-17 18:33:40 | 显示全部楼层
M1379 发表于 2015-7-17 15:15
直接从报错结果看,是不是你实际进行了两次 configuration bits 的配置 ?

比如,在你的 config.h 文件里有 ...

问题找到了,是重复定义了。

一处是在mcc.c这个文件里面。这个文件是用MPLAB Code Configurator Resources 自动生成的代码。

若复制配置界面的输出代码进工程,就和这个冲突了。

就这这么简单,被折磨了两天。

这个编辑器的报错功能确实不怎么样,就说重定义了在哪哪文件里,就省事多了。
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-5-1 13:14

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表