本帖最后由 zhangmangui 于 2014-1-22 09:14 编辑
void Show(Uint16 i)
{
StopCpuTimer0(); //停止计数
DISABLE_TIMER1_INT; //不使能定时中断
ConfigCpuTimer(&CpuTimer0, 150, Musi); //设置定时时间
StartCpuTimer0(); //重启定时器
ENABLE_TIMER1_INT; //使能定时中断
Delay(DT); //音乐节拍延时
StopCpuTimer0(); //停止计数
DISABLE_TIMER1_INT; //不使能定时中断
BUZZ_OFF; //关闭蜂鸣器 //音乐停顿
}
// Prototype statements for functions found within this file.
interrupt void cpu_timer0_isr(void);
void main(void)
{
InitSysCtrl();
Buzz_Gpio_Init();
DINT;
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.TINT0 = &cpu_timer0_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
// Step 4. Initialize the Device Peripheral. This function can be
// found in DSP2833x_CpuTimers.c
InitCpuTimers(); // For this example, only initialize the Cpu Timers
ConfigCpuTimer(&CpuTimer0, 150, 50);
// to CPU-Timer 2:
IER |= M_INT1;
// Enable TINT0 in the PIE: Group 1 interrupt 7
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
while(1)
{
//Read_KX(1);
Read_KX(2);
//Read_KX(3);
//Read_KY(1);
Read_KY(2);
//Read_KY(3);
Show(key);
}
}
interrupt void cpu_timer0_isr(void)
{
CpuTimer0.InterruptCount++;
BUZZ_CLK_GENER;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
在main主函数中执行show函数,为什么脉冲的发送不是连续的呢?只发声一下就没了,而且在重启DSP时,执行又是按下1键就响个不停,那个while函数不是死循环吗?就应该一直执行里面的程序呀,show函数执行了,就应该执行configcputimer,然后就会执行中断了,那就会发脉冲了,不是吗? |