![]() |
發布時間: 2018-5-22 16:25
正文摘要:在聯調過程中內部存儲的歌曲,按下播放鍵可以正常播放, 但是琴鍵按下之后沒有反應,數碼管也不能顯示數字。 這是在keil中調試之后的結果: 程序如下: #include "reg51.h" #define shumaguan P ... |
程序本身沒有語法錯誤,是你沒有留空格。 switch(P2) //檢測按鍵,輸出數碼管、載入定時器初值、允許中斷 { case 0xfe:shumaguan=0x1;tone1=0xfb;tone2=0xe9;EA=1;break; case 0xfd:shumaguan=0x2;tone1=0xfc;tone2=0x5c;EA=1;break; case 0xfb:shumaguan=0x3;tone1=0xfc;tone2=0xc1;EA=1;break; case 0xf7:shumaguan=0x4;tone1=0xfc;tone2=0xef;EA=1;break; case 0xef:shumaguan=0x5;tone1=0xfd;tone2=0x45;EA=1;break; case 0xdf:shumaguan=0x6;tone1=0xfd;tone2=0x92;EA=1;break; case 0xbf:shumaguan=0x7;tone1=0xfd;tone2=0xd0;EA=1;break; case 0x7f:shumaguan=0x1;tone1=0xfd;tone2=0xee;EA=1;break; default: EA=0;SPK=0;shumaguan=0x00;//沒有鍵按下則關閉中斷和數碼管 } |
所有的“case0xfe:”改成case 0xfe: 軟件不會有warnings。功能沒有幫你看。 至少能學會能查出語法錯誤,再查自己的功能錯誤。 |