本帖最后由 xys9190 于 2022-3-30 11:03 编辑
void PWM1_Init(uint16_t cnt, uint16_t duty)
{
PWM1PH = (uint8_t)(cnt>>8);
PWM1PL = (uint8_t)(cnt&0xFF);
PWM1DH = (uint8_t)(duty>>8);
PWM1DL = (uint8_t)(duty&0xFF);
PWM1CON = BIT3|BIT1|BIT0; // clk_hirc | 8 prescaled
PWMEN |= BIT1; // Enable PWM1
}
PWM1_Init(62,31); //P11 //主函数里面调用该函数进行PWM1的初始化,62为周期,31为占空比.
|