用的stm32f103C8T6 TIM1 CH4通道 PA11 用keil自带的逻辑仿真没波形
void PWMInit(void)
{ //PA11 I_Vref
RCC.APB2ENR.bit.TIM1EN = 1;
RCC.APB2ENR.bit.IOPAEN = 1;
RCC.APB2ENR.bit.AFIOEN = 1;
AFIO.MAPR.bit.TIM1_REMAP = 0;
GPIOA.CRH.bit.MODE11 = 3;
GPIOA.CRH.bit.CNF11 = 2;
TIM1.ARR.bit.ARR = 9999;
TIM1.PSC.bit.PSC = 0;
TIM1.CCMR2.bit.OC4M = 6;
TIM1.CCER.bit.CC4P = 0;
TIM1.CCMR2.bit.OC4PE = 0;
TIM1.CCER.bit.CC4E = 1;
TIM1.CR1.bit.ARPE = 1;
TIM1.CCR4.bit.CCR4 = 5000;
TIM1.CR1.bit.CEN = 1;
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>