stm8 pwm实现核心代码

原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: stm8 pwm实现核心代码
void TIM2_Config(void)
{
        CLK_PCKENR1 |= 0x20;//TIM2 CLK Enable!
        asm("nop");
        while(!(CLK_PCKENR1 & 0x01));
        TIM2_CR1 = 0x00;

        TIM2_PSCR = 0x00;//16/2^4

        TIM2_ARRH = 0x00;
        TIM2_ARRL = 0xFF;//

        TIM2_CCR1H = 0x01;
        TIM2_CCR1L = 0xf4;

        TIM2_CCR2H = 0x1;
        TIM2_CCR2L = 0xf4;

        TIM2_CCR3H = 0x01;
        TIM2_CCR3L = 0xf4;

        TIM2_CCMR1 = 0x70;
        TIM2_CCMR2 = 0x70;
        TIM2_CCMR3 = 0x70;

        TIM2_CCER1 = 0x33;
        TIM2_CCER2 = 0x03;

        TIM2_IER = 0x00;
        TIM2_CR1 |= 0x01;
        //TIM2_BKR = 0xc0;
}

STM8S103F3P6  输出 3路 PWM

亲测可用。

原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: stm8 pwm实现核心代码

文章的脚注信息由WordPress的wp-posturl插件自动生成



|2|left
打赏

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: