调试一个tim1通道1输出PWM,一直是低电平,不知道为什么,求解,下面是代码:
#include "iostm8s103f3.h"
void TIM1_Init()
{
TIM1_CCMR1 = 0x60;
TIM1_CCER1 = 0x05;
//初始化自动装载寄存器,决定PWM方波的频率,
TIM1_ARRH = 0;
TIM1_ARRL = 0x05;
//初始化比较寄存器,决定PWM方波的占空比
TIM1_CCR1H = 0;
TIM1_CCR1L = 3;
// 初始化时钟分频器为1,
TIM1_PSCRH = 0x00;
TIM1_PSCRL = 0x00;
//初始化刹车寄存器
TIM1_BKR=0x80;
// 启动计数
TIM1_CR1 = 0x01;
}
void main(void)
{
CLK_CKDIVR=0x10;//4分频
TIM1_Init();
while(1);
} |