TIM1->CR1 = 0x04;
TIM1->SMCR = 0;//禁止从模式
TIM1->IER = 0;//禁止所有中断
TIM1->CCER1 = 0; //禁止PWM输出
TIM1->CCER2 = 0;
TIM1->CCMR1 = 0x60; //PWM1模式,禁止预装载,通道配置为输出
TIM1->CCMR2 = 0x60;
TIM1->CCMR3 = 0x60;
//prescale = div1 @ 16MHz -> 62.5ns/count, Full scale = 4.09ms
TIM1->PSCRH = 0;
TIM1->PSCRL = 0;
TIM1->ARRH=hArrPwmVal/256; //PWM周期设定
TIM1->ARRL=hArrPwmVal%256;
//disable repetition counter
TIM1->RCR = 0;
TIM1->CCR1H=0;TIM1->CCR1L=0;//占空比输出均为0
TIM1->CCR2H=0;TIM1->CCR1L=0;
TIM1->CCR3H=0;TIM1->CCR1L=0;
此帖出自
小平头技术问答
62.5ns*65536=4.096ms
赋值0就是最大周期计数
一周热门 更多>