|
|
如果用T1中断控制音符节拍的话,那就需要的T1中断里设置一个中断标记,如tmr2ms, 中断发声时置1. 然后在下面的语句里加上一个判断,就可以用T1中断来控制节拍时间。这样更方便人理解程序中节拍的设置。 for (beat=0; beat<sizeof(TwoTigerNote); ) { while (!tmrflag); // tmrflag = 0; if (tmr2ms==1) { tmr2ms=0; if (time == 0) { note = TwoTigerNote[beat] - 1; T0RH = NoteReload[note] >> 8; T0RL = NoteReload[note]; beatTime = (TwoTigerBeat[beat] * 250) >> 2; //这里也需要改一下,楼主的时间中断是2ms一次,所以250个中断才能表示500ms. soundTime = beatTime - (beatTime >> 2); enable = 1; time++; } else { if (time >= beatTime) { time = 0; beat++; } else { time++; if (time == soundTime) { enable = 0; } } } } } |