- #include <reg51.h>
- sbit SPK=P1^0;
- unsigned char TH,TL;
- unsigned long int PL[]={64426,64400,64524,64580,
- 64684,64777,64820,64898,
- 64968,65030,65058,65110,
- 65157,65178,65217};
- unsigned char YF[]={8,0,8,9,8,10,11,0,
- 8,0,8,9,8,12,11,0,
- 8,0,8,15,13,11,10,9,
- 14,0,14,13,11,12,11,0,0xFF};
- unsigned char JP[]={2,1,1,4,4,4,4,4,
- 2,1,1,4,4,4,4,4,
- 2,1,1,4,4,4,4,4,
- 2,1,1,4,4,4,4,4};
- main()
- {
- void delayms(unsigned char ms);
- unsigned char I;
- unsigned int YF_Z,JP_Z;
- TMOD=0x01;
- IE=0x82;
- I=0;
- while(YF[I]!=0xFF)
- {
- YF_Z=YF[I];
- if(YF[I]==0) TR0=0;
- else
- {
- TH=PL[YF_Z-1]/256;
- TL=PL[YF_Z-1]%256;
- TR0=1;
- }
- JP_Z=JP[I};
- delayms(JP_Z);
- I++;
- }
- }
- void time0_int (void) interrupt 1 using 1
- {
- TH0=TH;
- TL0=TL;
- SPK=~SPK;
- }
- void delayms(unsigned char ms)
- {
- unsigned char i;
- while(ms--)
- {
- for(i=0;i<120*187;i++);
- }
- }
复制代码
|