TIM1能否在产生pwm的同时,在计数器达到峰值时产生一个中断?

2019-07-21 02:29发布

我利用TIM1产生了一路pwm,想要在pwm计数器达到峰值时产生一个中断给我用,不知行不行?我配置了TIM1_UP_IRQHandler,是中断发生时PB5反转,但仿真时,pwm有波形而pb5没有波形,配置如下
[mw_shl_code=c,true]TIM_ITConfig(TIM1,TIM_IT_Update,ENABLE ); //???????¨??TIM1????,???í?ü?????? NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_IRQn; //TIM3???? NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //??????????0?? NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //????????3?? NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ?¨??±????? NVIC_Init(&NVIC_InitStructure); //?ù??NVIC_InitStruct?????¨???????????????èNVIC?????÷[/mw_shl_code]
中断函数
[mw_shl_code=c,true]void TIM1_UP_IRQHandler(void) { if ( TIM_GetITStatus(TIM1 , TIM_IT_Update) != RESET ) { TIM_ClearITPendingBit(TIM1, TIM_FLAG_Update); LED0=!LED0; } } [/mw_shl_code] 问题
1.在计数器达到峰值时能否有中断给我用,有的话用哪一个?
2.我配置的中断为何没有发生?PB5一直为低电平
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。