前面定义的全局变量数组wenzi[]最后应该是分号,而不是逗号。
延时子程序中用了库函数_nop_();必须用#include包含头文件intrins.h。因为没加头文件,_nop_()是不识别的,才引起变量p错误。
两个延时子程序前面要加void,否则编译时会警告。
主程序中还有几处错误,修改如下图
㈡ 单片机程序编译的时候出错了,要看的只有三条语句。
前面那个是赋值运算,P3 ^ 4就是P3的值和4做异或运算,结果是一个常数,给常数赋值当然是错误的;
后面那句是判等,P3 ^ 0 == 1等同于P3 ^(0==1)就是P3的值和0做异或运算,再判断结果是否为真,这样的运算是符合规定的,所以不会报错,只是结果不是你想象的了
㈢ pic单片机编译经常出现的错误有哪些
编译器只能识别语法错误,没办法判断那种单片机会错误,那种单片机不会错。编译出现的错误,只能归结为
LZ
的
C语言水平不够,或者
打字不够细心。
但PIC
单片机使用的
注意点倒是不少,最让人
闹心的就是,PIC
默认打开
AD
功能,要想把引脚当
普通
IO
使用,必须
自行关闭
AD功能。很多初学者,连IO操作都没开始,就必须先操作特殊功能了,你说闹不闹心。
另外,PIC的
硬件堆栈也是个注意点,低级(便宜)的型号,硬件堆栈可能只有
2~3层,高级(贵货)的可以达到16层,普通型号也有7~8层了。这玩意是用来计算“函数
调用
函数
调用
函数”的层数的,主函数算0,主函数开始调用的功能子函数算1,功能子函数调用的驱动子函数算2……
㈣ 单片机编译时出现错误
A51中$可以调用一些指定的控制指令,例如文件的调用$include (c8051f040.inc)
$NOMOD51;使A51汇编器预定义的SFR无效等
当$后面跟的指令错误或无效时。就会出现这种错误提示。
下面是所有的$调用的控制指令
CASE Primary Enables case-sensitive symbol names.
COND General Includes (in the listing file) conditional source lines skipped by the preprocessor.
DATE Primary Specifies the date to use in the listing file header.
DEBUG Primary Includes debugging information in the object file.
DEFINE Primary Defines C preprocessor symbols on the command line.
ECRM Primary Allow expansion of generic CALL instruction to ECALL for the NXP 80C51MX devices.
EJECT1 General Inserts a form feed character into the listing file.
ELSE General Assemble block if the condition of a previous IF is false.
ELSEIF General Assemble block if condition is true and a previous IF or ELSEIF is false.
ENDIF General Ends an IF block.
ERRORPRINT Primary Specifies the file name for error messages.
GEN General Includes all macro expansions in the listing file.
IF General Assemble block if condition is true.
INCDIR Primary Sets additional include file paths.
INCLUDE2 General Includes the contents of another file.
LIST General Includes the assembly source text in the listing file.
MACRO Primary Enables preprocessor expansion of standard macros.
MOD_CONT Primary Enables 24-bit contiguous addressing for Dallas Semiconctor devices.
MOD_MX51 Primary Enables instruction set extensions for the NXP 80C51MX architecture.
MOD51 Primary Enables code generation and defines SFRs for classic 8051 devices.
MPL Primary Enables preprocessor expansion of MPL macros.
NOAMAKE Primary Excludes build information from the object file.
NOCASE Primary Disables case-sensitive symbol names. All symbols are converted to uppercase.
NOCOND Primary Excludes (from the listing file) conditional source lines skipped by the preprocessor.
NODEBUG Primary Excludes debugging information from the object file.
NOERRORPRINT Primary Disables error messages output to the screen.
NOGEN General Excludes macro expansions from the listing file.
NOLINES Primary Excludes line number information from the generated object mole.
NOLIST General Excludes the assembly source text from the listing file.
NOMACRO Primary Disables preprocessor expansion of standard and MPL macros.
NOMOD51 Primary Suppresses SFRs definitions for classic 8051 devices
NOMPL Primary Disables preprocessor expansion of MPL macros.
NOOBJECT Primary Disables object file generation.
NOPRINT Primary Disables listing file generation.
NOREGISTERBANK Primary Disables memory space reservation for register banks.
NOSYMBOLS Primary Excludes the symbol table from the listing file.
NOSYMLIST General Excludes subsequently defined symbols from the symbol table.
NOXREF Primary Excludes the cross-reference table from the listing file.
OBJECT Primary Specifies the name for the object file.
PAGELENGTH Primary Specifies the number of lines on a page in the listing file.
PAGEWIDTH Primary Specifies the number of characters on a line in the listing file.
PRINT Primary Specifies the name for the listing file.
REGISTERBANK Primary Reserves memory space for register banks.
REGUSE General Specifies registers modified by the specified function.
RESET General Sets symbols, which may be tested by IF or ELSEIF, to false.
RESTORE1 General Restores settings for the LIST and GEN directives.
SAVE1 General Saves settings for the LIST and GEN directives.
SET General Sets symbols, which may be tested by IF or ELSEIF, to true or a specified value.
SYMBOLS Primary Includes the symbol table in the listing file.
SYMLIST General Includes subsequently defined symbols in the symbol table.
TITLE Primary Specifies the page header title in the listing file.
XREF Primary Includes the cross-reference table in the listing file.
㈤ 这个单片机程序老是提示语法错误,该怎么处理
这程序不是你自己写的吧,大括号用的太乱了,好多地方不成对;你把各个函数都划分开,仔细排查一下;我实在看得眼花;
㈥ 紧急请教各位高手关于51单片机编译出错的问题
A9--错误是语法错误。因为你的LOOP后面的:不是英文状态的,还有下面的DELAY,D1,D2后面的。
A3--错误是字符没有定义,去掉后面的分号;--这不是C语言。好用P10改为P1.0--中间的.也是英文的,语句中间的逗号,也要改为英文的。改掉这些就可以通过了。我编译通过。
㈦ 单片机C语言编译错误
已经好了。
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit la=P2^6;
sbit wela=P2^7;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delayms(uint);
void main()
{
while(1)
{
la=1;
P0=table[1]; //送段选数据
la=0;
P0=0xff;
wela=1;
P0=0xfe;
wela=0;
delayms(1000);
la=1;
P0=table[2]; //送段选数据
la=0;
P0=0xff;
wela=1;
P0=0xfd;
wela=0;
delayms(1000);
la=1;
P0=table[3]; //送段选数据
la=0;
P0=0xff;
wela=1;
P0=0xfb;
wela=0;
delayms(1000);
la=1;
P0=table[4]; //送段选数据
la=0;
P0=0xff;
wela=1;
P0=0xf7;
wela=0;
delayms(1000);
la=1;
P0=table[5]; //送段选数据
la=0;
P0=0xff;
wela=1;
P0=0xef;
wela=0;
delayms(1000);
la=1;
P0=table[5]; //送段选数据
la=0;
P0=0xff;
wela=1;
P0=0xdf;
wela=0;
delayms(1000);
la=1;
P0=table[6]; //送段选数据
la=0;
P0=0xff;
wela=1;
P0=0x7f;
wela=0;
delayms(1000);
}
}
void delayms(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
㈧ 单片机c语言用keil编译时出现如下的错误是什么原因'=':illegal type conversion from/to 'void',急求
Write_24C02 ();
下方错误提示显示的是,这个函数返回类型是 void 也就是没有设定返回值,所以使用 = 等号 就产生了语法错误。
㈨ 如图,请问单片机这样编程提示错误,哪里语法错误了
第一个错误是 DEC 未定义,
此外100行花括号不匹配,后面还有多处花括号不匹配。
写程序要注意书写规范,要不然就是自找麻烦…
㈩ 单片机编程时为什么总出现syntax error
这个东西可能是你的编译程序没安装好,或者是你在编译时开了多个文本程序,导致编译不出,系统报错