原先PB4脚在TIM3定时中断里翻转,可以测出1K的方波,现改用PWM功能,一直无法输出PWM波形
RCC->AHBENR|=1<<18; //使能PORTB时钟
GPIOB->MODER = 0X55551655; //PB4复用功能输出
GPIOB->OTYPER = 0X00000000; //推挽输出
GPIOB->OSPEEDR = 0X00000000; //低速
GPIOB->PUPDR = 0X00004000;
RCC->APB1ENR|=1<<1; //TIM3时钟使能
TIM3->PSC=47; //预分频器48分频
TIM3->ARR=1000; //设置频率
TIM3->CCR1 =500; //设置占空比
TIM3->EGR |= 1; //产生一次更新事件
TIM3->CCMR1|=7<<4; //CH1 PWM2模式
TIM3->CCMR1|=1<<3; //CH1预装载使能
TIM3->CCER|=1<<0; //OC1输出使能
TIM3->CR1=0x0080; //ARPE使能
TIM3->CR1|=0x01; //使能定时器3 |