哪位好心人能帮我看看这个程序问题出在哪里,是制作一个简易电子琴,真心感谢啊!一直运行不成功
#include #include #define uchar unsigned char #define uint unsigned int ***it buz=P0^0; uchar keycode; /*各音阶对应计数器初值:1,2,3,4,5,6,7,1(高)*/ uint toneh[8]={ 0xfc43,0xfcab,0xfd08,0xfd32,0xfd81,0xfdc7,0xfe05,oxfe21}; uchar keymode [8]={ 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; void main() { Sys_Init(); do { keycode=Get_Key(); /*获取键值索引*/ Play(keycode); } } unchar Get_Key () { uchar temp,i; p1=0xff; temp=P1; for (i=0;i<8;i++) { if (temp==keymode ) return i; } return (8); //无正确对应的键值,则忽略 } void sys_init() { TMOD=0x10; /*启动定时器1*/ EA=1; /*开总中断*/ ET1=1; /*允许定时器1中断*/ P1=0xff; /*设置P1口为输入模式*/ } void play (uchar key) { if (key==8)/*无键按下或多键按下,不响应*/ { TR1=0; buz=0; } else { TR1=1; /*有键按下,开中断*/ keycode=key; /*键值索引赋值*/ } } void timer 0(void) interrupt 3 using 1 /*定时器1中断服务程序*/ { buz= !buz; TH0=toneh[keycode]/256; /*获取各键对应的乐音频率所需的定时器高位初值*/ TL0=tonel[keycode]%256; /*获取各键对应的乐音频率所需的定时器低位初值*/ }
|