我想设置电机每隔1s改变占空比,为什么进去中断一次之后后就不会循环?求指教
interrupt void TINT0_isr(void) // CPU-Timer 0
{
CpuTimer0.InterruptCount++;
if((increase==1)&&(decrease==0)) //如果占空比越来越小
{
EvaRegs.CMPR1=EvaRegs.CMPR1+938;
if(EvaRegs.CMPR1>=0x41EB)
{
EvaRegs.CMPR1=0x41EB; //占空比到达最小的10%时,改变变化的方向
increase=0;
decrease=1;
}
}
if((increase==0)&&(decrease==1)) //如果占空比越来越大
{
EvaRegs.CMPR1=EvaRegs.CMPR1-938;
if(EvaRegs.CMPR1<=0x0753)
{
EvaRegs.CMPR1=0x0753; //占空比到达最大的90%时,改变变化的方向
increase=1;
decrease=0;
}
CpuTimer0Regs.TCR.bit.TIF=1; //
PieCtrl.PIEACK.bit.ACK1=1; //
EINT; //开全局中断
|