刚开始学32,就想在TIM1的CH1上产生PWM,问一下下面的初始化定时器的代码哪里有问题?
RCC->APB2ENR |= 0X00000800; //使能TIM1时钟
RCC->APB2ENR |= 0X00000005; //使能PA口时钟,使能复用功能时钟
GPIOA->CRH &= 0Xfffffff0;
GPIOA->CRH |= 0X0000000b; //PA8为复用推挽输出
//NVIC->ISER[0] = 1<<25;
TIM1->PSC = 72*100; //72M/7200=10000HZ 为计数频率
TIM1->ARR = 10;
TIM1->CCMR1|= 0X0060; //CC1通道配置为输出,PWM模式1
TIM1->CCR1 = 5; //比较值(占空比调节)
TIM1->CCER |= 0X0001; //使能CC1输出
//TIM1->DIER |= 0X0001;
TIM1->CR1 = 0x0003; //禁止更新,启动定时器
|