TIM4->CCR4=480;//设定占空比50% //TIM4->DIER |= TIM_DIER_CC4IE;//允许捕获/比较4中断 TIM...
TIM4->CCR4 = ccrEnd-ccrBeg; } }}int main(void){ u8 res; u8 prev_flag = 0; //hand open when start. u8 five_flag = 0;//the 5 low bits control 5 channels pwm LED_Init(); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); My_usart1_init(); delay_init(168); TIM4_PWM_Init(100...
TIM4->CCR4=500; TIM4->CCMR2|=(6<<12);//PWM模式样 TIM4->CCMR2|=(1<<11);//开启预装载功能 TIM4->CCER|=(1<<12);//CH4 开启输出对应管脚 TIM4->CCER|=0<<13;//高电平有效 TIM4->CR1|=0<<4;//向上计数 TIM4->CR1|=(1<<7);//自动重装允许 TIM4->SR=0X00; TIM4->DIER|=...
51. 52. TIMx->CCR4 = cnt_tar; /* 设置捕获比较计数器CC4 */ 53. TIMx->SR = (uint16_t)~TIM_IT_CC4; /* 清除CC4中断标志 */ 54. TIMx->DIER |= TIM_IT_CC4; /* 使能CC4中断 */ 55. } 56. else 57. { 58. return; 59. } 60. } 1. 2. 3. 4. 5. 6. 7. 8. 9...
前面两个通道被重映射了!
(uint16_t)~TIM_IT_CC3;/*清除CC3中断标志*/46. TIMx->DIER |= TIM_IT_CC3;/*使能CC3中断*/47. }48.elseif(_CC ==4)49. {50. s_TIM_CallBack4 = (void(*)(void))_pCallBack;51.52. TIMx->CCR4 = cnt_tar;/*设置捕获比较计数器CC4*/53. TIMx->SR = (uint16_t)~TIM_IT_CC...
* TIM3 Channel4 duty cycle = (TIM3_CCR4/ TIM3_ARR)* 100 = 12.5% * --- *//* Time base configuration */TIM_TimeBaseStructure.TIM_Period = PWM_ARR; TIM_TimeBaseStructure.TIM_Prescaler =0; TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD...
(uint16_t)~TIM_IT_CC3;/* 清除CC3中断标志 */46.TIMx->DIER|=TIM_IT_CC3;/* 使能CC3中断 */47.}48.elseif(_CC==4)49.{50.s_TIM_CallBack4=(void(*)(void))_pCallBack;51.52.TIMx->CCR4=cnt_tar;/* 设置捕获比较计数器CC4 */53.TIMx->SR=(uint16_t)~TIM_IT_CC4;/* 清除CC...
(uint16_t)~TIM_IT_CC3;/*清除CC3中断标志*/46. TIMx->DIER |= TIM_IT_CC3;/*使能CC3中断*/47. }48.elseif(_CC ==4)49. {50. s_TIM_CallBack4 = (void(*)(void))_pCallBack;51.52. TIMx->CCR4 = cnt_tar;/*设置捕获比较计数器CC4*/53. TIMx->SR = (uint16_t)~TIM_IT_CC...
TIM4->CCR4=500;TIM4->CCMR2|=(6<<12);//PWM模式样 TIM4->CCMR2|=(1<<11);//开启预装载功能 TIM4->CCER|=(1<<12);//CH4 开启输出对应管脚 TIM4->CCER|=0<<13;//高电平有效TIM4->CR1|=0<<4;//向上计数 TIM4->CR1|=(1<<7);//自动重装允许 ...