请大佬看一下,为什么不能播放出当前的音乐,一直只有滴滴声,而播放不出音乐
单片机源程序如下:- #include <reg51.h>
- #define uchar unsigned char
- #define uint unsigned int
- sbit fm=P1^0; //??????IO?
- sbit k1=P3^2;
- uchar timeh,timel,i; //timeh,timel??????4?,i???????
- bit flag;
- //---------------------------??---------------------------------------
- //1-7????do~si,8????do
- uchar code qnzl[]={0x12,0x22,0x34,0x84,0x74,0x54,0x38,0x42,0x32,0x22,0x42,0x34,0x84,0x72,0x82,0x94,
- 0x08,
- 0x32,0x31,0x21,0x32,0x52,0x32,0x31,0x21,0x32,0x62,
- 0x32,0x31,0x21,0x32,0x82,0x71,0x81,0x71,0x51,0x32,0x22,
- 0x32,0x31,0x21,0x32,0x52,0x32,0x31,0x21,0x32,0x62,
- 0x32,0x31,0x21,0x32,0x83,0x82,0x71,0x72,0x02,
- 0x63,0xA1,0xA2,0x62,0x92,0x82,0x52,
- 0x31,0x51,0x63,0x51,0x63,0x51,0x63,0x51,0x62,0x82,0x7C,0x02,
- 0x61,0x71,0x82,0x71,0x62,0xA2,0x71,0x76,
- 0x61,0x71,0x82,0x71,0x62,0x52,0x31,0x36,
- 0x61,0x71,0x82,0x71,0x62,0xA3,0x73,0x62,0x53,
- 0x42,0x63,0x83,0x83,0x91,0x91,
- 0x61,0x71,0x82,0x71,0x62,0x0A2,0x71,0x76,
- 0x61,0x71,0x82,0x71,0x62,0x52,0x31,0x36,
- 0x61,0x71,0x82,0x71,0x62,0xA3,0x73,0x62,0x53,
- 0x42,0x82,0x88,0x02,0x74,0x93,0x89,0xff
-
- };
- //----------------------------????????????---------------------------
- uchar code jmszl[]={ 0x17,0x01, 0x15,0x01, 0x17,0x01, 0x15,0x01, 0x0F,0x02,
- 0x15,0x02, 0x17,0x02, 0x15,0x02, 0x17,0x01, 0x15,0x01,
- 0x17,0x02, 0x17,0x03, 0x17,0x03, 0x18,0x02, 0x19,0x02,
- 0x17,0x66, 0x16,0x03, 0x16,0x01, 0x15,0x02, 0x15,0x03,
- 0x15,0x03, 0x16,0x02, 0x17,0x02, 0x17,0x66, 0x11,0x03,
- 0x11,0x01, 0x10,0x02, 0x17,0x02, 0x16,0x01, 0x10,0x02,
- 0x17,0x02, 0x16,0x01, 0x10,0x02, 0x17,0x02, 0x16,0x66,
- 0x15,0x02, 0x15,0x00, 0x17,0x02, 0x17,0x03, 0x17,0x03,
- 0x18,0x02, 0x19,0x02, 0x17,0x66, 0x16,0x03, 0x16,0x01,
- 0x15,0x02, 0x15,0x03, 0x15,0x03, 0x16,0x02, 0x17,0x02,
- 0x17,0x66, 0x11,0x03, 0x11,0x01, 0x10,0x02, 0x17,0x02,
- 0x16,0x01, 0x10,0x02, 0x17,0x02, 0x16,0x01, 0x10,0x02,
- 0x17,0x02, 0x16,0x66, 0x15,0x03, 0x15,0x00, 0x17,0x03,
- 0x16,0x03, 0x19,0x00, 0x18,0x03, 0x17,0x03, 0x17,0x03,
- 0x16,0x03, 0x16,0x01, 0x19,0x03, 0x18,0x03, 0x17,0x02,
- 0x18,0x03, 0x19,0x66, 0x17,0x02, 0x16,0x14, 0x15,0x03,
- 0x10,0x02, 0x17,0x02, 0x16,0x66, 0x15,0x03, 0x0F,0x02,
- 0x16,0x03, 0x15,0x03, 0x15,0x01, 0x18,0x03, 0x17,0x03,
- 0x18,0x03, 0x17,0x03, 0x15,0x01, 0x18,0x03, 0x17,0x03,
- 0x18,0x03, 0x17,0x03, 0x15,0x66, 0x16,0x03, 0x15,0x00,
- 0x17,0x02, 0x17,0x03, 0x17,0x03, 0x18,0x02, 0x19,0x02,
- 0x17,0x66, 0x16,0x03, 0x16,0x01, 0x15,0x02, 0x15,0x03,
- 0x15,0x03, 0x16,0x02, 0x17,0x02, 0x17,0x66, 0x11,0x03,
- 0x11,0x01, 0x10,0x02, 0x17,0x02, 0x16,0x01, 0x0F,0x02,
- 0x16,0x02, 0x15,0x01, 0x18,0x03, 0x17,0x03, 0x18,0x03,
- 0x17,0x03, 0x15,0x01, 0x16,0x00, 0x15,0x00, 0x00,0x00 };
- uchar code cuzhi[]={ 0xff,0xff,
- 0xfc,0x44, 0xfc, 0xad, 0xfd,0x0a,0xfd,0x34,0xfd,0x83,0xfd,0xc8,0xfe,0x06,
- 0xfe,0x22, 0xfe,0x57, 0xfe,0x85, 0xfe,0x9b,0xfe, 0xc2, 0xfe,0xe4, 0xff,0x03};
-
- void delay1(uint z); //??1ms???
- void delay(uint z); //??165ms,?1/4????
- void song(); //?????
- main()
- {
- EA=1; //????
- ET0=1;
- EX0=1;
- IT0=1;
- EX1=1;//?????1
- IT1=1; //????0
- TMOD=0x01; //???0?????1
- TH0=0;
- TL0=0;
- ET0=1;
- while(1)
- {
- if(k1==0)flag=0;
- else flag=1;
- song();
- delay1(1000);
- }
- }
-
-
-
- void timer0() interrupt 1 //???0???????????????
- {
- TH0=timeh;
- TL0=timel;
- fm=~fm; //????
- }
- void song()
- {
- uint temp;
- uchar jp; //jp???1~8???
- i=0;
- while(1)
- { if(flag==0)
- temp=qnzl[i];
- else temp=jmszl[i];
- if(temp==0xff) break; //????????
- jp=temp/16; //????4?????
- if(jp!=0)
- {
- timeh=cuzhi[jp*2]; //?T??4??
- timel=cuzhi[jp*2+1]; //?T??4??
- }
- else
- {
- TR0=0;
- fm=1; //????
- }
- delay(temp%16); //????4?????
- TR0=0; //??????10ms
- fm=1;
- delay1(10);
- TR0=1;
- i++;
- }
- TR0=0;
- fm=1;
- }
- void delay(uint z) //??165ms,?1/4?
- {uint x;
- for(x=0;x<z;x++)
- delay1(165);
- }
- void delay1(uint ms) //??1ms
- {uint i,j;
- for(i=0;i<ms;i++)
- for(j=0;j<110;j++);
- }
复制代码 |