使用TIM1输出PWM波,定时器初始化程序如下:
void TIM1_Init(void)
{
TIM1_PSCR=0x00;
TIM1_ARRH=0x03;
TIM1_ARRL=0xE8;
TIM1_CCMR1=0x60;
TIM1_CCMR2=0x60;
TIM1_CCMR3=0x60;
TIM1_SR1=0x00;
TIM1_DTR=0x1F;
TIM1_CCER1=0x00;
TIM1_CCER2=0x00;
TIM1_EGR=0x01;
TIM1_OISR=0x2A;
TIM1_BKR=0x80;
TIM1_CR1=0x01;
}
主程序如下:
main()
{
System_Init();
while(1)
{
TIM1_CCR1H=0x01;
TIM1_CCR1L=0xA8;
TIM1_CCER1=0x0D;//上下桥输出相同的波形,使用的2103
}
}
相同的程序,用STM8S207单片机不断复位,而用STM105C4则运行正常,这是怎么回事?这两款单片机的TIM1有什么不同么?如果确实不同,我想用STM8S207的TIM1输出上下桥相同的波形该怎么设置?急急急,望解答!!!! |