使用了6路PWM驱动电机,使能了刹车功能,也开启了刹车中断允许,还开起了EXTI_IMR 和 EMR 刹车信号输入后,PWM波形全部消失,进入刹车状态。就是不进中断,烦死了。
/*主输出能使 刹车能使 高电平刹车 空闲状态无论定时器运行与否均起效,死区时间2.5us 120*1/48us*/
TIM1->BDTR = 120|(TIM_BDTR_MOE | TIM_BDTR_OSSI | TIM_BDTR_OSSR | TIM_BDTR_LOCK_1) | TIM_BDTR_BKE ;
/*TIM1 自动重载 向上计数*/
TIM1->CR1 = TIM_CR1_ARPE | TIM_CR1_CEN;
//TIM1->EGR = TIM_EGR_BG;
EXTI->IMR |= 0X2000; //开启Exti 13
EXTI->EMR |= 0X2000; //开启Exti 13
TIM1->SR &= (!TIM_SR_BIF);
TIM1->DIER= TIM_DIER_BIE; //开启刹车中断允许
TIM_CtrlPWMOutputs(TIM1, ENABLE);
void TIM1_BRK_UP_TRG_COM_IRQHandler(void) //中断函数
{
TIM1->SR &= (!TIM_SR_BIF);
}
|