完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我是Microchip的新产品,有XC8编译器和链接器。我为个人项目写了这个小代码,但我不明白它为什么不编译…我用8位PIC16F82。我在同一目录里有3个文件:“LP.16F82.H”、“LP16F82.C”和“NeNeM.C”。编译器输出:我使用最新版本的XC8软件之一谢谢你。
以上来自于百度翻译 以下为原文 Hello, i'm new with microchip's products and with XC8 compiler and linker. I wrote this little code for a personnal project but i don't understand why it do not compile... I use the 8 bits PIC16F882. I have 3 files in the same directory : "lp.16f882.h", "lp16f882.c" and "newmain.c". lp.16f882.h code #define TMR0_INTERNAL_CLOCK 1 #define TMR0_EXT_CLOCK 0 #define TMR0_PRESCALER_2 B'00000000' #define TMR0_PRESCALER_4 B'00000001' #define TMR0_PRESCALER_8 B'00000010' #define TMR0_PRESCALER_16 B'00000011' #define TMR0_PRESCALER_32 B'00000100' #define TMR0_PRESCALER_64 B'00000101' #define TMR0_PRESCALER_128 B'00000110' #define TMR0_PRESCALER_256 B'00000111' extern void configuretimer0(uint8_t, bit); lp16f882.c code #include #include void configureTimer0(uint8_t prescaler, bit sourceSelect ) { // TMR1 sur 8 bit if((prescaler&1)!=0)OPTION_REG |= 1; else OPTION_REG &= ~(1 << 0); if((prescaler&2)!=0)OPTION_REG |= 2; else OPTION_REG &= ~(1 << 1); if((prescaler&4)!=0)OPTION_REG |= 4; else OPTION_REG &= ~(1 << 2); OPTION_REG &= ~(1<<3); // clear PSA if(sourceSelect)OPTION_REG &= ~(1<<5); return; } newmain.c // CONFIG1 #pragma config FOSC = EXTRC_CLKOUT// Oscillator Selection bits (RC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, RC on RA7/OSC1/CLKIN) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config MCLRE = OFF // RE3/MCLR pin function select bit (RE3/MCLR pin function is digital input, MCLR internally tied to VDD) #pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled) #pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled) #pragma config BOREN = OFF // Brown Out Reset Selection bits (BOR disabled) #pragma config IESO = ON // Internal External Switchover bit (Internal/External Switchover mode is enabled) #pragma config FCMEN = ON // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is enabled) #pragma config LVP = ON // Low Voltage Programming Enable bit (RB3/PGM pin has PGM function, low voltage programming enabled) // CONFIG2 #pragma config BOR4V = BOR40V // Brown-out Reset Selection bit (Brown-out Reset set to 4.0V) #pragma config WRT = OFF // Flash Program Memory Self Write Enable bits (Write protection off) #include #include "lp16f882.h" int main(void){ configureTimer0(TMR0_PRESCALER_256,TMR0_INTERNAL_CLOCK); while(1); return; } and the compiler output : make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf make[1]: Entering directory 'C:/Users/brice/MPLABXProjects/testc.X' make -f nbproject/Makefile-default.mk dist/default/production/testc.X.production.hex make[2]: Entering directory 'C:/Users/brice/MPLABXProjects/testc.X' "C:Program Files (x86)Microchipxc8v1.41binxc8.exe" --pass1 --chip=16F882 -Q -G --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=-3 --asmlist -DXPRJ_default=default --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -obuild/default/production/newmain.p1 newmain.c make[2]: *** [build/default/production/newmain.p1] Error 1 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 (908) exit status = 1 nbproject/Makefile-default.mk:108: recipe for target 'build/default/production/newmain.p1' failed make[2]: Leaving directory 'C:/Users/brice/MPLABXProjects/testc.X' nbproject/Makefile-default.mk:84: recipe for target '.build-conf' failed make[1]: Leaving directory 'C:/Users/brice/MPLABXProjects/testc.X' nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed BUILD FAILED (exit value 2, total time: 1s) I use one of the latest version of the software xc8 Thank you in advance. Bisouke |
|
相关推荐
19个回答
|
|
我至少会先包括,然后是语用。正好相反。但这只是一个受过教育的猜测。
以上来自于百度翻译 以下为原文 I'd at least #include first, then #pragma. Exactly the other way round. But this is just a somehow educated guess. |
|
|
|
好了,谢谢你的提示DU000 00 000,即使这真的不改变编译器的问题;
以上来自于百度翻译 以下为原文 ok thank you for the tips du00000001 even if this don't realy change the compiler issue ;) |
|
|
|
B’00000000是无效的。也许你的意思是0亿。
以上来自于百度翻译 以下为原文 B'00000000' is not valid C. Maybe you meant 0b00000000. |
|
|
|
这不是问题,也不是正确的方法。在语用上,应首先避免语用重置。
以上来自于百度翻译 以下为原文 That is not the problem, and it is not the correct way of doing it. #pragma should come first to avoid macro replacement in the #pragmas. |
|
|
|
是的,我的意思是0BXXXXXXX(X是0或1),我改变了代码,但我仍然有同样的问题;谢谢
以上来自于百度翻译 以下为原文 Yes i meant 0bxxxxxxxx (where x is 0 or 1) i changed my code but i still have the same problem ;) Thank you |
|
|
|
我刚才看到,我不应该使用“位”作为函数原型中的一种变量:所以我再次更改了代码,但这并不能解决问题:(
以上来自于百度翻译 以下为原文 I just saw that i shouldn't use 'bit' as a type of variable in a function prototype like : void configureTimer0(uint8_t prescaler, BIT sourceSelect ) { // TMR1 sur 8 bit So i changed my code again but this don't resolve the problem :(( |
|
|
|
你的MPLAX和XC8工作正常吗?我在输出中没有看到任何不正常的错误消息。
以上来自于百度翻译 以下为原文 Is your MPLAB X and XC8 working correctly? I don't see any error messages in the output which is not normal. |
|
|
|
它看起来像是“某物”的“突然死亡”。在输入文件或类似的LIKE CTRL Z…
以上来自于百度翻译 以下为原文 It's really looking like "sudden death" of "something". Linke Ctrl-Z in an input file or alike... |
|
|
|
应该如何配置?自从安装以来,我没有改变任何东西…我认为这是编译器/链接器的错误信息,不是吗?
以上来自于百度翻译 以下为原文 How should it be configured ? i didn't change nothing since the installation... I thought this was error message from the compiler/linker no ? make[2]: *** [build/default/production/newmain.p1] Error 1 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 BUILD FAILED (exit value 2, total time: 1s) |
|
|
|
“错误1”不是来自编译器,而是来自编译系统。在此之后应该有编译器错误。你的IDE里有些东西不对劲。
以上来自于百度翻译 以下为原文 "Error 1" is not from the compiler, it's from the build system. You should have compiler errors following that. Something looks wrong in your IDE. |
|
|
|
我试着用同样的3个文件创建一个新的项目,但是这是一样的…
以上来自于百度翻译 以下为原文 I tried to create a new project with the same 3 files, but this is the same... |
|
|
|
尝试一个新的项目,一个空的主()和其他。
以上来自于百度翻译 以下为原文 Try a new project with an empty main() and nothing else. |
|
|
|
也许这是因为Mag文件?我真的不知道它是什么,我没有碰它。
以上来自于百度翻译 以下为原文 Maybe this is due to the makefile ? i don't really know what it is and i didn't touched it |
|
|
|
我已经尝试编写另一个新项目,打开我的开发板上的LED,它工作得很好…
以上来自于百度翻译 以下为原文 I already tried to compile another new project which turn on the LEDs on my developpement board and it works very well... |
|
|
|
即使当我把所有的3个文件放在同一个.c文件中,这也不起作用。
以上来自于百度翻译 以下为原文 Even when i put all the 3 files in the same main.c file like this this don't work.. /* * File: main.c * Author: brice * * Created on 1 mars 2017, 18:27 */ // CONFIG1 #include #include #pragma config FOSC = EXTRC_CLKOUT// Oscillator Selection bits (RC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, RC on RA7/OSC1/CLKIN) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config MCLRE = OFF // RE3/MCLR pin function select bit (RE3/MCLR pin function is digital input, MCLR internally tied to VDD) #pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled) #pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled) #pragma config BOREN = OFF // Brown Out Reset Selection bits (BOR disabled) #pragma config IESO = ON // Internal External Switchover bit (Internal/External Switchover mode is enabled) #pragma config FCMEN = ON // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is enabled) #pragma config LVP = ON // Low Voltage Programming Enable bit (RB3/PGM pin has PGM function, low voltage programming enabled) // CONFIG2 #pragma config BOR4V = BOR40V // Brown-out Reset Selection bit (Brown-out Reset set to 4.0V) #pragma config WRT = OFF // Flash Program Memory Self Write Enable bits (Write protection off) #define TMR0_INTERNAL_CLOCK 1 #define TMR0_EXT_CLOCK 0 #define TMR0_PRESCALER_2 0b00000000 #define TMR0_PRESCALER_4 0b00000001 #define TMR0_PRESCALER_8 0b00000010 #define TMR0_PRESCALER_16 0b00000011 #define TMR0_PRESCALER_32 0b00000100 #define TMR0_PRESCALER_64 0b00000101 #define TMR0_PRESCALER_128 0b00000110 #define TMR0_PRESCALER_256 0b00000111 void configureTimer0(uint8_t prescaler, char sourceSelect ) { // TMR1 sur 8 bit if((prescaler&1)!=0)OPTION_REG |= 1; else OPTION_REG &= ~(1 << 0); if((prescaler&2)!=0)OPTION_REG |= 2; else OPTION_REG &= ~(1 << 1); if((prescaler&4)!=0)OPTION_REG |= 4; else OPTION_REG &= ~(1 << 2); OPTION_REG &= ~(1<<3); // clear PSA if(sourceSelect)OPTION_REG &= ~(1<<5); return; } int main(void){ configureTimer0(TMR0_PRESCALER_256,TMR0_INTERNAL_CLOCK); while(1); return; } |
|
|
|
在输出日志中应该有一些错误消息…
以上来自于百度翻译 以下为原文 There should be some error message in your output log... |
|
|
|
|
|
|
|
这不是你原来的帖子。那是你的错误。
以上来自于百度翻译 以下为原文 This was not in your original post. That is your error. |
|
|
|
这不是你原来的帖子。那是你的错误。
以上来自于百度翻译 以下为原文 This was not in your original post. That is your error. exactly |
|
|
|
只有小组成员才能发言,加入小组>>
4814 浏览 9 评论
1823 浏览 8 评论
1743 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
2949 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2055 浏览 5 评论
452浏览 1评论
1107浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
355浏览 0评论
260浏览 0评论
LAN9252使用SQI通信,进行数字复位后读BYTE_TEST异常
1777浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-4-20 12:07 , Processed in 3.920706 second(s), Total 87, Slave 76 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号