導航:首頁 > 源碼編譯 > 單片機語法編譯錯誤

單片機語法編譯錯誤

發布時間:2022-04-28 04:21:16

單片機C語言 keil編譯這些錯誤怎麼改

前面定義的全局變數數組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

這個東西可能是你的編譯程序沒安裝好,或者是你在編譯時開了多個文本程序,導致編譯不出,系統報錯

閱讀全文

與單片機語法編譯錯誤相關的資料

熱點內容
單片機簡單實驗 瀏覽:776
創易的文件夾怎麼拼 瀏覽:868
javaffmpeglinux 瀏覽:942
文件夾如何改成空白名 瀏覽:564
單片機一秒延遲程序函數庫 瀏覽:461
軟體測試人員屬於程序員嗎 瀏覽:914
android自定義dialog樣式 瀏覽:198
怎麼給d盤裡面文件加密 瀏覽:566
右鍵轉換為pdf 瀏覽:857
程序員那麼可愛免費觀看全集92 瀏覽:238
不用軟體如何加密視頻 瀏覽:39
pdfeditor免安裝 瀏覽:341
iphone怎麼設置app消息靜音 瀏覽:826
愛快app如何使用 瀏覽:198
編譯型語言都不開源嗎 瀏覽:307
誇克app怎麼設置中文 瀏覽:585
壓縮機氣閥異響後正常 瀏覽:428
程序員小剛生活記錄 瀏覽:683
wrf編譯出現的exe是紅色的 瀏覽:850
威綸通如何將編譯錯誤設置不報錯 瀏覽:800