新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > ICC錯誤集錦,看懂ICC AVR的報錯

        ICC錯誤集錦,看懂ICC AVR的報錯

        作者: 時間:2016-10-19 來源:網絡 收藏

          新手用編程的時候,經常會出現一些錯誤,現在將常見的錯誤報告整理如下。這里的一些錯誤是我為了展示而故意制造的,歡迎你提供你遇到的錯誤。排名不分先后:

        本文引用地址:http://www.104case.com/article/201610/311530.htm

          一、正常編譯通過

          CODE:

          C:iccbinimakew -f main.mak

          iccavr -c -IC:iccinclude -e -DATMEGA -DATMega16 -l -g -Mavr_enhanced D:桌面實驗教程LED應用霓虹燈main.c

          iccavr -o main -LC:icclib -g -ucrtatmega.o -bfunc_lit:0x54.0x4000 -dram_end:0x45f -bdata:0x60.0x45f -dhwstk_size:16 -beeprom:1.512 -fihx_coff -S2 @main.lk -lcatmega

          Device 1% full.

          Done.

          [Copy to clipboard]

          這是我們最想看到的了,萬事大吉。

          二、工程中未加入.C文件

          CODE:

          C:iccbinimakew -f main.mak

          iccavr -o main -LC:icclib -g -ucrtatmega.o -bfunc_lit:0x54.0x4000 -dram_end:0x45f -bdata:0x60.0x45f -dhwstk_size:16 -beeprom:1.512 -fihx_coff -S2 @main.lk -lcatmega

          unknown file type @main.lk, passed to linker

          !ERROR unknown file type '@main.lk'

          C:iccbinimakew.exe: Error code 1

          Done: there are error(s). Exit code: 1

          [Copy to clipboard]

          解決辦法:將你的程序加入工程中,可以右鍵程序區>>ADD to project

          三、程序沒有后綴名,或者后綴名不正確。

          CODE:

          C:iccbinimakew -f main.mak

          C:iccbinimakew.exe: 'main' is up to date

          Done.

          [Copy to clipboard]

          這是一個很難理解的錯誤,它是由工程中的程序文件沒有后綴名造成的。

          解決辦法:將原有文件移出工程,將文件的后綴名改為.C,然后再加入工程中。

          四、沒有main函數

          CODE:

          C:iccbinimakew -f main.mak

          iccavr -c -IC:iccinclude -e -DATMEGA -DATMega16 -l -g -Mavr_enhanced D:桌面實驗教程LED應用霓虹燈main.c

          iccavr -o main -LC:icclib -g -ucrtatmega.o -bfunc_lit:0x54.0x4000 -dram_end:0x45f -bdata:0x60.0x45f -dhwstk_size:16 -beeprom:1.512 -fihx_coff -S2 @main.lk -lcatmega

          !ERROR file 'crtatmega.o': undefined symbol '_main'

          C:iccbinimakew.exe: Error code 1

          Done: there are error(s). Exit code: 1

          [Copy to clipboard]

          解決辦法,編寫程序主函數MAIN。

          五、沒有選擇目標芯片出現如下錯誤:

          CODE:

          C:iccbinimakew -f main.mak

          iccavr -c -IC:iccinclude -e -l -g -Wa-W D:桌面實驗教程LED應用霓虹燈main.c

          iccavr -o main -LC:icclib -g -Wl-W -bfunc_lit:0.0x2000 -dram_end:0x25f -bdata:0x60.0x25f -dhwstk_size:16 -beeprom:1.512 -fihx_coff -S2 @main.lk

          !E C:icclibcrt.o(41): Code address 0 already contains a value

          !E C:icclibcrt.o(41): Code address 0x1 already contains a value

          C:iccbinimakew.exe: Error code 1

          Done: there are error(s). Exit code: 1

          [Copy to clipboard]

          解決辦法:project>>Options>>target>>device configuration 選擇合適的芯片。

          六、缺少分號

          CODE:

          C:iccbinimakew -f main.mak

          iccavr -c -IC:iccinclude -e -DATMEGA -DATMega16 -l -g -Mavr_enhanced D:桌面實驗教程LED應用霓虹燈main.c

          !E D:桌面實驗教程LED應用霓虹燈main.c(52): unrecognized statement

          !E D:桌面實驗教程LED應用霓虹燈main.c(53): syntax error; found `}' expecting `;'

          !E D:桌面實驗教程LED應用霓虹燈main.c(53): syntax error; found `end of input' expecting `}'

          C:iccbinimakew.exe: Error code 1

          C:iccbinimakew.exe: 'main.o' removed.

          Done: there are error(s). Exit code: 1

          [Copy to clipboard]

          上面的報告說明了第52行缺少一個分號,預期分號的地方出現了“}”。

          解決方法,在52行末尾添加分號。

          類似的有:缺少}的報錯

          CODE:

          C:iccbinimakew -f main.mak

          iccavr -c -IC:iccinclude -e -DATMEGA -DATMega16 -l -g -Mavr_enhanced D:桌面實驗教程LED應用霓虹燈main.c

          !E D:桌面實驗教程LED應用霓虹燈main.c(55): illegal statement termination

          !E D:桌面實驗教程LED應用霓虹燈main.c(55): skipping `void'

          !W D:桌面實驗教程LED應用霓虹燈main.c(55):[warning] calling function without prototype may cause errors

          !E D:桌面實驗教程LED應用霓虹燈main.c(56): syntax error; found `{' expecting `;'

          !E D:桌面實驗教程LED應用霓虹燈main.c(57): syntax error; found `end of input' expecting `}'

          C:iccbinimakew.exe: Error code 1

          C:iccbinimakew.exe: 'main.o' removed.

          Done: there are error(s). Exit code: 1

          [Copy to clipboard]

          七:變量沒有定義

          CODE:

          C:iccbinimakew -f main.mak

          iccavr -c -IC:iccinclude -e -DATMEGA -DATMega16 -l -g -Mavr_enhanced D:桌面實驗教程LED應用霓虹燈main.c

          !E D:桌面實驗教程LED應用霓虹燈main.c(48): undeclared identifier `i'

          C:iccbinimakew.exe: Error code 1

          C:iccbinimakew.exe: 'main.o' removed.

          Done: there are error(s). Exit code: 1

          [Copy to clipboard]

          解決辦法:在程序開始前添加變量定義,比如unsigned char i;注意,定義變量要在函數的最前面進行,及在進行計算操作之前定義所有變量。

          歡迎你發布你遇到的錯誤和解決方法,或者你遇到的錯誤還沒解決的。

          八、在編譯時總是不能生成COF文件,不能進行調試

          解決辦法:在編譯環境中,進入Project -> Option -> Compiler中在Output format區選COFF/HEX格式

          九、請指點一下:

          我的程序出現下列錯誤提示,是不是我什么地方設置錯了呀。

          CODE:

          D:iccbinimakew -f tex.mak

          -lstudio -lfpavr

          want size 346

          lo 3910 hi 4096 size 187

          !E (37): area 'text' not large enough

          D:iccbinimakew.exe: Error code 1

          Done: there are error(s). Exit code: 1

          一點錯誤那行的時候就出來一個提示框,但沒有移到某一行上去。。。。

          ans1:還沒有確切的解釋,可能原因:應該是定義的數組過大,減小數組的數量應該可以了

          ans2:這是超過編譯空間了,你可以到壓縮下代碼,project>options>compiler,選擇Enable code compression或者只有優化代碼了

          十:無意中又發現一個:

          too many arguments to `delay_1ms'

          問題原因,函數的參數太多,比如上面一個定義的是delay_1ms(void),我確用了delay_1ms(1);改為delay_1ms();就好了。

          十一、!ERROR can't open file 'libiccavrlibsliccatmega-m.a'

          剛才問了一下人,新建一個工程,然后把所有的C文件都導入里面,就沒有的問題了,剩下一些語法錯誤。

          十二、7 的代碼大小限制的問題,DEMO版超過4K不能編譯。

          D:PROGRA~1iccv7avrbinimakew -f mytest.mak

          D:PROGRA~1iccv7avrbinimakew.exe: Couldn't open mytest GetLastError() = 5

          Done: there are error(s). Exit code: 1

          (斑竹,我后來發現這好像是因為ICC編譯生成的某些文件有錯誤,把ICC生成的文件都刪掉,重新建立一個project,重新選擇Target,重新編譯就好了)

          十三、

          CODE:

          iccavr -o main -LD:avricclib -g -ucrtatmega.o -bfunc_lit:0x8c.0x10000 -dram_end:0x10ff -bdata:0x100.0x10ff -dhwstk_size:16 -beeprom:1.2048 -fihx_coff -S2 @main.lk D:PROTEU~1.7PROTEU~1.7JOHUmcuallCH375HFB.A -lcatmega

          Device 45% full.

          warning: COFF no struct tag '_CMD_PARAM' found for symbol index 1362

          Done.

          一個警告,搞不太清楚,以前starnewtech說過,好像是ram不夠用了。

          十四、重復定義 ,請在包含的頭文件里面用這種格式。

          #ifndef __config_H__

          #define __config_H__ 1

          //你的定義放這里。

          #endif



        關鍵詞: ICC AVR

        評論


        相關推薦

        技術專區

        關閉
        主站蜘蛛池模板: 淮南市| 日喀则市| 望奎县| 昌图县| 涪陵区| 龙口市| 河西区| 宁波市| 定安县| 错那县| 安新县| 南汇区| 灌云县| 胶南市| 横峰县| 吉首市| 封丘县| 上虞市| 桦川县| 苍南县| 文化| 墨玉县| 潢川县| 鞍山市| 庄河市| 陆丰市| 正镶白旗| 施秉县| 新建县| 西充县| 肇东市| 广水市| 哈巴河县| 湖州市| 岳阳县| 潼南县| 嘉义县| 库尔勒市| 稷山县| 林口县| 根河市|