21ic问答首页 - 求助STC8H4K64TL单片机无法输出PWM4P_4, 详情如下
求助STC8H4K64TL单片机无法输出PWM4P_4, 详情如下
scvi2022-07-26
void main()
{
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0x00;
P2M1 = 0x00;
P3M0 = 0x00;
P3M1 = 0x00;
P4M0 = 0x00;
P4M1 = 0x00;
P5M0 = 0x00;
P5M1 = 0x00;
P_SW2 = 0x80;
PWMA_CCER1 = 0x00; //写CCMRx前必须先清零CCERx关闭通道
PWMA_CCMR1 = 0x60; //设置CC1为PWMA输出模式
PWMA_CCER1 = 0x01; //使能CC1通道
PWMA_CCR4 = 100; //设置占空比时间
PWMA_ARR = 200; //设置周期时间
PWMA_ENO = 0x40; //使能PWM4P端口输出
PWMA_PS = 0XC0;
PWMA_BKR = 0x80; //使能主输出
PWMA_CR1 = 0x01; //开始计时
while (1);
}
搜索
下载视频
{
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0x00;
P2M1 = 0x00;
P3M0 = 0x00;
P3M1 = 0x00;
P4M0 = 0x00;
P4M1 = 0x00;
P5M0 = 0x00;
P5M1 = 0x00;
P_SW2 = 0x80;
PWMA_CCER1 = 0x00; //写CCMRx前必须先清零CCERx关闭通道
PWMA_CCMR1 = 0x60; //设置CC1为PWMA输出模式
PWMA_CCER1 = 0x01; //使能CC1通道
PWMA_CCR4 = 100; //设置占空比时间
PWMA_ARR = 200; //设置周期时间
PWMA_ENO = 0x40; //使能PWM4P端口输出
PWMA_PS = 0XC0;
PWMA_BKR = 0x80; //使能主输出
PWMA_CR1 = 0x01; //开始计时
while (1);
}
搜索
复制
下载视频
您需要登录后才可以回复 登录 | 注册