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);
}
搜索
复制
下载视频
|