| 
  |||||||||||
| 技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測(cè)控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng) 驅(qū)動(dòng)編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機(jī) | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計(jì) | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe  | 
  
各們,小弟有一事不解...幫幫忙.. | 
  
| 作者:阿柑 欄目:單片機(jī) | 
小的剛接觸單片機(jī).學(xué)用C編程..但是編程時(shí)很煩..老是不對(duì)...哎.. 各位幫我看看下面哪里錯(cuò)啦!! #include <reg51.h> #define BYTE unsigned CHAR BYTE time ; BYTE preiod=20; BYTE high_time=4; sbit P1_0=P1^0; void clock_initial(); rectrant using 0 { TCON=0x00; TL0=0xB0; TH0=0x3C; TR0=0; } void main() { clock_initial(); ET=1; EA=1; while(1); } void CLK_int(void) intrerupt 1 using 0 { time=time+1; if(time==high_time) {P1_0=0;} else if (time==period) {P1_0=1; time=0; } clock_initial(); } 這又是什么東東? 123.C(10): error C129: missing ';' before '{' 123.c - 1 Error(s), 0 Warning(s).  | 
  
| 2樓: | >>參與討論 | 
| 作者: 曉勇 于 2005/12/3 21:01:00 發(fā)布:
         不知對(duì)不對(duì),共同討論 問題在于你的粗心大意,打字錯(cuò)了 BYTE preiod=20;與else if (time==period)的period不一樣哦 void clock_initial();分號(hào)去掉 rectrant using 0 中rectrant改為reentrant ET=1;改為ET0=1; void CLK_int(void) intrerupt 1 using 0 改interrupt 逐個(gè)改改看,就會(huì)發(fā)現(xiàn)問題了,還有,不知可不可用哦,沒有設(shè)置TMOD  | 
  |
| 3樓: | >>參與討論 | 
| 作者: 阿柑 于 2005/12/3 23:01:00 發(fā)布:
         多謝呀... 其實(shí)這是老師給我們的作業(yè).. 利用12MHZ晶振,在P1.0引腳上輸出周期為1S,占空比為%20和脈沖信號(hào)..哎.不會(huì)做..老是出錯(cuò).. 改了..更多錯(cuò)了.怎么辦..明天要交作業(yè)...哎..難學(xué)呀. #include <reg51.h> #define BYTE unsigned CHAR BYTE time ; BYTE preiod=20; BYTE high_time=4; sbit P1_0=P1^0; void clock_initial() rectrant using 0 { TCON=0x00; TL0=0xB0; TH0=0x3C; TR0=0; } void main() { TOMD=0x01; clock_initial(); ET0=1; EA=1; while(1); } void CLK_int(void) interrupt 1 using 0 { time=time+1; if(time==high_time) {P1_0=0;} else if (time==preiod) {P1_0=1; time=0; } clock_initial(); } 各們幫幫手.看看還有哪里錯(cuò)呀.. 以下是KEIL的錯(cuò)誤信息... compiling 123.c... 123.C(10): error C132: 'rectrant': not in formal parameter list 123.C(10): error C141: syntax error near 'using' 123.C(12): error C244: 'TCON': can't initialize, bad type or class 123.C(12): error C132: 'TCON': not in formal parameter list 123.C(13): error C244: 'TL0': can't initialize, bad type or class 123.C(13): error C132: 'TL0': not in formal parameter list 123.C(14): error C244: 'TH0': can't initialize, bad type or class 123.C(14): error C132: 'TH0': not in formal parameter list 123.C(15): error C244: 'TR0': can't initialize, bad type or class 123.C(15): error C132: 'TR0': not in formal parameter list 123.C(16): error C141: syntax error near '}' 123.C(20): error C202: 'TOMD': undefined identifier 123.c - 12 Error(s), 0 Warning(s). 煩..  | 
  |
| 4樓: | >>參與討論 | 
| 作者: 曉勇 于 2005/12/3 23:28:00 發(fā)布:
         …… rectrant using 0 中rectrant改為reentrant 你都還沒有改啊 TMOD不是TOMD 粗心做不好事的!  | 
  |
| 5樓: | >>參與討論 | 
| 作者: 阿柑 于 2005/12/3 23:43:00 發(fā)布:
         哈哈..終于好啦... #include <reg51.h> #define BYTE unsigned CHAR BYTE time ; BYTE preiod=20; BYTE high_time=4; sbit P1_0=P1^0; void clock_initial() reentrant using 0 { TCON=0x00; TL0=0xB0; TH0=0x3C; TR0=0; } void main() { TMOD=0x01; clock_initial(); ET0=1; EA=1; while(1); } void CLK_int(void) interrupt 1 using 0 { time=time+1; if(time==high_time) {P1_0=0;} else if (time==preiod) {P1_0=1; time=0; } clock_initial(); } 成功了... compiling 123.c... 123.c - 0 Error(s), 0 Warning(s). 多謝曉勇 ..我以后會(huì)細(xì)心點(diǎn)的啦..哈哈.明天有作業(yè)交啰..  | 
  |
| 6樓: | >>參與討論 | 
| 作者: 艾森豪威爾 于 2005/12/5 8:39:00 發(fā)布:
         呵呵!想起我剛開始學(xué)C語言的時(shí)候了!  | 
  |
  | 
    
 
  | 
  
| 免費(fèi)注冊(cè)為維庫電子開發(fā)網(wǎng)會(huì)員,參與電子工程師社區(qū)討論,點(diǎn)此進(jìn)入 | 
Copyright © 1998-2006 www.udpf.com.cn 浙ICP證030469號(hào)  |