1. code unsigned char FREQH[] = {
    2. 0xF2, 0xF3, 0xF5, 0xF5, 0xF6, 0xF7, 0xF8, //低音1234567
    3. 0xF9, 0xF9, 0xFA, 0xFA, 0xFB, 0xFB, 0xFC, 0xFC, //1,2,3,4,5,6,7,i
    4. 0xFC, 0xFD, 0xFD, 0xFD, 0xFD, 0xFE, //高音 234567
    5. 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF}; //超高音 1234567
    6. // 频率-半周期数据表 低八位
    7. code unsigned char FREQL[] = {
    8. 0x42, 0xC1, 0x17, 0xB6, 0xD0, 0xD1, 0xB6, //低音1234567
    9. 0x21, 0xE1, 0x8C, 0xD8, 0x68, 0xE9, 0x5B, 0x8F, //1,2,3,4,5,6,7,i
    10. 0xEE, 0x44, 0x6B, 0xB4, 0xF4, 0x2D, //高音 234567
    11. 0x47, 0x77, 0xA2, 0xB6, 0xDA, 0xFA, 0x16}; //超高音 1234567
    12. void t0int() interrupt 1 //T0中断程序,控制发音的音调
    13. {
    14. TR0 = 0; //先关闭T0
    15. beep = !beep; //输出方波, 发音
    16. TH0 = FREQH[k]; //下次的中断时间, 这个时间, 控制音调高低
    17. TL0 = FREQL[k];
    18. TR0 = 1; //启动T0
    19. }