STM8S003 TIM2 PWM无输出,发现写不入寄存器,,直接在IAR仿真时手动修改就能正常输出PWM,不知为什么,求原因
void TIM2_Init(void)
{
TIM2_ARRH = 0x27; //设定重装载值
TIM2_ARRL = 0x10; //
TIM2_CCR1H = 0; //设置占空比
TIM2_CCR1L = 20; //
TIM2_CCER1 = 0x01; //高电平有效,开启输出
TIM2_CCMR1 = 0x68; ////PWM模式1;通道2PWM输出
TIM2_CR1 = 0x01; //计数使能
}
写入寄存器后结果
TIM2_ARRH =0x00
TIM2_ARRL = 0x14
TIM2_CCR1H = 0x00
TIM2_CCR1L = 0x00
TIM2_CCER1 = 0x00
TIM2_CCMR1 = 0x00
TIM2_CR1 = 0x01; |