熱門: 51單片機(jī) | 24小時(shí)必答區(qū) | 單片機(jī)教程 | 單片機(jī)DIY制作 | STM32 | Cortex M3 | 模數(shù)電子 | 電子DIY制作 | 音響/功放 | 拆機(jī)樂園 | Arduino | 嵌入式OS | 程序設(shè)計(jì)
![]() |
發(fā)布時(shí)間: 2018-5-22 16:25
正文摘要:在聯(lián)調(diào)過程中內(nèi)部存儲的歌曲,按下播放鍵可以正常播放, 但是琴鍵按下之后沒有反應(yīng),數(shù)碼管也不能顯示數(shù)字。 這是在keil中調(diào)試之后的結(jié)果: 程序如下: #include "reg51.h" #define shumaguan P ... |
程序本身沒有語法錯(cuò)誤,是你沒有留空格。 switch(P2) //檢測按鍵,輸出數(shù)碼管、載入定時(shí)器初值、允許中斷 { 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;//沒有鍵按下則關(guān)閉中斷和數(shù)碼管 } |
所有的“case0xfe:”改成case 0xfe: 軟件不會有warnings。功能沒有幫你看。 至少能學(xué)會能查出語法錯(cuò)誤,再查自己的功能錯(cuò)誤。 |
Powered by 單片機(jī)教程網(wǎng)