测试使用的是PWM1[4]、PWM1[5]、PWM1[6],单独配置任意一个,pwm控制都没有问题,但同时使用PWM1[4]和PWM1[5],会导致PWM1[5]输出的占空比不对,同时使用PWM1[5]和PWM1[6],会导致PWM1[6]输出的占空比不对,
但同时使用PWM1[4]和PWM1[6],2路PWM输出都正常
以下是同时配置两路PWM的程序,请各位大佬帮忙看看哪里配置的有问题
u32 temp;
rPWM_IOCON_USE &= ~0x07;
rPWM_IOCON_USE_2 &= ~0x07;
temp = Chip_Clock_GetPeripheralClockRate() / 1000;
rPWM_PR = 0x00;
rPWM_MCR = 0x02;
rPWM_PCR = (1 << 5) | (1 << 13) | (1 << 6) | (1 << 14);
rPWM_MR0 = temp;
rPWM_MR5 = 0;
//占空比为5%
rPWM_MR5 = (temp * 5) / 100;
rPWM_MR6 = 0;
//占空比为5%
rPWM_MR6 = (temp * 5) / 100;
rPWM_LER = 0x7F;
rPWM_TCR = 0x02;
rPWM_TCR = 0x09;
rPWM_IOCON_USE |= 1;
rPWM_IOCON_USE_2 |= 1;
|