朋友们帮忙看看,个怎么进不了定时器中断?
EvaRegs.T1CON.bit.TMODE=2; //连续增模式
EvaRegs.T1CON.bit.TPS=1; //T1CLK=HSPCLK/2=37.5M
EvaRegs.T1CON.bit.TENABLE=0; //暂时禁止T1计数
EvaRegs.T1CON.bit.TCLKS10=0; //使用内部时钟,T1CLK
EvaRegs.T1CON.bit.TECMPR=1; //使能定时器比较操作
EvaRegs.T2CON.bit.TMODE=2; //连续增模式
EvaRegs.T2CON.bit.TPS=1; //T2CLK=HSPCLK/2=37.5M
EvaRegs.T2CON.bit.TENABLE=0; //暂时禁止T2计数
EvaRegs.T2CON.bit.TCLKS10=1; //使用内部时钟,T2CLK
EvaRegs.T2CON.bit.TECMPR=1; //使能定时器比较操作
EvaRegs.GPTCONA.bit.TCMPOE=1; //定时器比较输出T1PWM_T1CMPR和T2PWM_T2CMPR由各自的定时器比较逻辑驱动
EvaRegs.GPTCONA.bit.T1PIN=1; //低电平有效
EvaRegs.GPTCONA.bit.T2PIN=2; //高电平有效
EvaRegs.T1PR=0x927B; //1KHz的PWM,周期为1ms
EvaRegs.T1CMPR=0x3A98; //占空比为40%,低电平有效
EvaRegs.T1CNT=0;
EvaRegs.T2PR=0x927B; //1KHz的PWM,周期为1ms
EvaRegs.T2CMPR=0x57E4; //占空比为40%,高电平有效
EvaRegs.T2CNT=0;
EvaRegs.COMCONA.bit.CENABLE=1; //使能比较单元的比较操作
EvaRegs.COMCONA.bit.FCOMPOE=1; //全比较输出,PWM1-6引脚均由相应的比较逻辑驱动
EvaRegs.COMCONA.bit.CLD=2;
//死区时间为:4.27us
EvaRegs.DBTCONA.bit.DBT=10; //死区定时器周期,m=10
EvaRegs.DBTCONA.bit.EDBT1=1; //死区定时器1使能位
EvaRegs.DBTCONA.bit.EDBT2=1; //死区定时器2使能位
EvaRegs.DBTCONA.bit.EDBT3=1; //死区定时器3使能位
EvaRegs.DBTCONA.bit.DBTPS=4, //死区定时器预定标因子 Tdb=37.5M/16=2.34M
EvaRegs.ACTRA.all=0x0666; //设定引脚PWM1-PWM6的动作属性
EvaRegs.CMPR1=0x3A98; //PWM1占空比为40%
EvaRegs.CMPR2=0x3A98; //PWM3占空比为40%
EvaRegs.CMPR3=0x3A98; //PWM5占空比为40%
EvaRegs.EVAIMRA.bit.T1PINT = 1;
EvaRegs.EVAIMRA.bit.T1CINT = 1; |