发 帖  
原厂入驻New
实战多通道高速精密测温仪的全系列设计教程,以实际项目为依托,提升工程师核心竞争力!→点击立即抢购←
[问答] 目标误差配方错误
32 LED 代码
分享
嗨,我想写一个简单的LED电压表程序,并可以真正使用一些帮助。最初我有很多PLIB错误,但是我安装了外围库,这似乎解决了这个问题。但是,现在我遇到几个关于“目标食谱”的错误。我在论坛上搜索了好几天了,似乎无法修复它,所以非常感谢您的帮助。我使用的是MPLAB X IDE v3.35、XC8 v1.38和Linux Ubuntu。以下是我的代码:这里是收到的错误:make-f nbproject/Makefile-default.mk SUBPROJECTS=.build-confmake[1]:输入目录'/home/steve/MPLABXProjects/tester.X'make-f nbproject/Makefile-default.mk dist/default/./tester.X.hexmake[2]:输入目录'/home/steve/MPLABXProjects/tester.X'"/opt/microhip/xc8/v1.38/bin/xc8"--pAs1--.=18F45K22-Q-G--double=24--float=24--emi=wordwrite--opt=default,+asm,+asm file,-.,+space,-debug--addrqual=.e--mode=free-P-N255--warn=-3--asmlist-DXPRJ_default=default--.y=default--.y=default,-psect,-class,+mem,-hex,-file--output=default,+inhx032--runtime=default,+.,+in它,-保持,-no_启动,-下载,+config,+clib,-plib--output=-mcof,+clib,-plib--output=-mcof=-mcof,+elf:multiloc--stack=output=-elf=output=-mcof:mcof:mcof:auto:auto:auto:auto:auto:auto,+elf:auto:multiloc:multiloc--stack:multiloc:multiloc--stack=编译=编译:auto:auto:auto:auto:auto:auto:auto:auto"--err格式"--err格式=%f:%f:%f:%1%1%1%1 1 1:%1%1%1 1错误:(195)表达式syntaxtester.c:42:error:“)”expectedtester.c:44:warning:(345)不可达codetester.c:44:warning:(361)函数声明为隐式inttester.c:44:error:(195)expression syntaxtester.c:46:error:(194)”expectedtester.c:46:error:(195)expression syntaxtester.c:48:error(194)“)”expectedtester.c:50:error:(313)函数体expectdtester.c:51:error:(285)声明测试器中没有标识符。pectedtester.c:55:error:(285).iontester.c:55中没有标识符:warning:(374)缺少基本类型;int.edtester.c:55:error:(314);“expectedtester.c:56:error:(194)”)“expectedtester.c:58:error:(313)函数体expectedtester.c:59:error:(285)声明中没有标识符ster.c:59:warning:(374)缺少基本类型;int.edtester.c:59:error:(314);“expectedtester.c:60:error:(194)”)“expectedtester.c:60:warning:(371)缺少基本类型;int.edtester.c:60:error:(984)type redeclaredtester.c:60:error:(1098)变量的冲突声明_.”(tester.c:60)(908)退出状态=1nbproject/Makefile-default.mk:100:目标“build/default/./tester.p1”failedmake的配方[2]:离开目录“/home/steve/MPLABXProjects/tester.X'nbproject/Makefile-default.mk:84:目标“.build-conf”failedmake的配方[1]:离开导演y'/home/steve/MPLABXProjects/tester.X'nbproject/Makefile-impl.mk:39:target'.build-impl'failedmake[2]的配方:***[build/default/./tester.p1]Error 1make[1]:***[.build-conf]Error 2make:***[.build-impl]Error 2BUILD FAILED(出口值2,总时间:460ms)感激。我一直在看MaX文件,但是我对它很陌生,所以我真的不知道我在寻找什么。

以上来自于百度翻译


      以下为原文

    Hi,

I'm trying to write a simple LED Voltmeter program and could really use some help. Originally I was getting lots of plib errors, but I then installed the peripheral libraries, which seemed to resolve the issue. However, I'm now getting several errors referring to 'Recipe for target'.

I've been searching the forums for days and can't seem to fix it, so any help would be much appreciated.

I'm using MPLAB X IDE v3.35, XC8 v1.38 and Linux Ubuntu.

Here is my code:


#include <xc.h>
#include <adc.h>
#pragma config MCLRE = EXTMCLR, WDTEN = OFF, FOSC = HSHP
#define _XTAL_FREQ 8000000

#define LED01V PORTDbits.RD0
#define LED12V PORTDbits.RD1
#define LED23V PORTDbits.RD2
#define LED34V PORTDbits.RD3
#define LED45V PORTDbits.RD4

void main() {
    unsigned long Vin, mV;
   
    ANSELD = 0;
    ANSELA = 1;
    TRISD = 0;
    TRISA = 1;
   
    OpenADC(ADC_FOSC_2 & ADC_RIGHT_JUST & ADC_12_TAD,
            ADC_CH0 & ADC_INT_OFF,
            ADC_TRIG_CTMU & ADC_REF_VDD_VDD & ADC_REF_VDD_VSS);
   
    for(;;)
    {
        PORTD = 0;
        SelChanConvADC(ADC_CH0);
        while(BusyADC());
        Vin = ReadADC();
        mV = (Vin * 5000)>>10;
        
        IF(mV <==1000)
        {
            LED01V = 1;
        }
        elseif(mV>1000 && mV <==2000)
        {
            LED12V = 1;
        }
        elseif(mV>2000 && mV <==3000)
        {
            LED23V = 1;
        }
        elseif(mV>3000 && mV <==4000)
        {
            LED34V = 1;
        }
        elseif(mV>4000 && mV <==5000)
        {
            LED45V = 1;
        }
        __delay_ms(10);
   
    }
   
}

Here are the errors I'm receiving:

make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory '/home/steve/MPLABXProjects/tester.X'
make -f nbproject/Makefile-default.mk dist/default/production/tester.X.production.hex
make[2]: Entering directory '/home/steve/MPLABXProjects/tester.X'
"/opt/microchip/xc8/v1.38/bin/xc8" --pass1 --chip=18F45K22 -Q -G --double=24 --float=24 --emi=wordwrite --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,-download,+config,+clib,-plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto "--erRFormat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: aDVIsory: (%n) %s" -obuild/default/production/tester.p1 tester.c
tester.c:40: error: (195) expression syntax
tester.c:42: error: (194) ")" expected
tester.c:44: warning: (345) unreachable code
tester.c:44: warning: (361) function declared implicit int
tester.c:44: error: (195) expression syntax
tester.c:46: error: (194) ")" expected
tester.c:46: error: (195) expression syntax
tester.c:48: error: (194) ")" expected
tester.c:50: error: (313) function body expected
tester.c:51: error: (285) no identifier in declaration
tester.c:51: warning: (374) missing basic type; int assumed
tester.c:51: error: (314) ";" expected
tester.c:52: error: (194) ")" expected
tester.c:54: error: (313) function body expected
tester.c:55: error: (285) no identifier in declaration
tester.c:55: warning: (374) missing basic type; int assumed
tester.c:55: error: (314) ";" expected
tester.c:56: error: (194) ")" expected
tester.c:58: error: (313) function body expected
tester.c:59: error: (285) no identifier in declaration
tester.c:59: warning: (374) missing basic type; int assumed
tester.c:59: error: (314) ";" expected
tester.c:60: error: (194) ")" expected
tester.c:60: warning: (371) missing basic type; int assumed
tester.c:60: error: (984) type redeclared
tester.c:60: error: (1098) conflicting declarations for variable "_delay" (tester.c:60)
(908) exit status = 1
nbproject/Makefile-default.mk:100: recipe for target 'build/default/production/tester.p1' failed
make[2]: Leaving directory '/home/steve/MPLABXProjects/tester.X'
nbproject/Makefile-default.mk:84: recipe for target '.build-conf' failed
make[1]: Leaving directory '/home/steve/MPLABXProjects/tester.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [build/default/production/tester.p1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 460ms)


Any help would be much appreciated. I've been looking in the Makefile, but I'm new to this so I don't really know what I'm looking for.

Cheers

Steve
0
2019-7-19 06:57:51   评论 分享淘帖 邀请回答
7个回答
在你的if语句中去掉l&=========?

以上来自于百度翻译


      以下为原文

    get rid of the <== in your IF statements, they should be <=
2019-7-19 07:03:47 评论

举报

在处理错误消息时,总是从第一个开始,而不是最后一个。

以上来自于百度翻译


      以下为原文

    When dealing with error messages, always start with the FIRST one, not the LAST one.
 
2019-7-19 07:20:43 评论

举报

并写入LATX,而不是PORTX。

以上来自于百度翻译


      以下为原文

    And write to LATx , not PORTx.
2019-7-19 07:30:32 评论

举报

…把所有多余的东西都扔掉。

以上来自于百度翻译


      以下为原文

    ... and get rid of all those 
mV>X000 &&
as they are redundant.
2019-7-19 07:50:16 评论

举报

非常感谢你们的帮助,我真的很感激。我已经做了你们的建议。我也意识到我在“else if”之间没有空格。但是,我仍然收到错误消息,尽管少了很多。下面是我现在所犯的错误:有什么想法吗?

以上来自于百度翻译


      以下为原文

    Thanks a lot for the help guys, I really appreciate it.
I've made the changes you advised. I also realised I didn't have a space between the 'else if'.
 
However, I'm still receiving error messages, albeit a lot less.
 
Here are the errors I'm getting now:
 

 
Any ideas?
2019-7-19 08:07:51 评论

举报

它看起来像一个PLIB功能。你安装了吗?在编译器选项中检查外围设备库吗?

以上来自于百度翻译


      以下为原文

       _ReadADC
 
that looks like  a PLib function.
Did you install it?
Did you check use Peripheral libraries in the compiler options?
2019-7-19 08:17:48 评论

举报

干杯,NKurzman。现在开始工作了。非常感谢帮助的家伙。咧嘴笑:

以上来自于百度翻译


      以下为原文

    Cheers, NKurzman. It's working now.
 
Really appreciated the help guys. grin:
2019-7-19 08:24:15 评论

举报

只有小组成员才能发言,加入小组>>

44个成员聚集在这个小组

加入小组

创建小组步骤

关闭

站长推荐 上一条 /10 下一条

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