This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123 pwm模块给电调初始化的问题



PWM模块已经调好 能给出1到2毫秒的高电平

但给电调做初始化再给油门的程序时出了问题 要先烧初始化程序 再烧油门程序电机才转 一起烧的话电调就会嘀嘀嘀响 我看说明书上写油门信号太窄 可我在stm32上做就没这个问题啊

初始化程序

void motor_init(void)
{
 SysCtlClockSet(SYSCTL_SYSDIV_1);
 SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
 GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6);
 GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7);
 GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_4);
 GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_5);
 GPIOPinConfigure(GPIO_PB6_M0PWM0);   
 GPIOPinConfigure(GPIO_PB7_M0PWM1);   
 GPIOPinConfigure(GPIO_PB4_M0PWM2);
 GPIOPinConfigure(GPIO_PB5_M0PWM3);
  PWMGenConfigure(PWM0_BASE,PWM_GEN_1,PWM_GEN_MODE_UP_DOWN| PWM_GEN_MODE_NO_SYNC);
 PWMGenConfigure(PWM0_BASE,PWM_GEN_0,PWM_GEN_MODE_UP_DOWN| PWM_GEN_MODE_NO_SYNC);
 PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 2500);
 PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, 2500);
 PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 0);
 PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, 0);
 PWMPulseWidthSet(PWM0_BASE, PWM_OUT_2, 0);
 PWMPulseWidthSet(PWM0_BASE, PWM_OUT_3, 0);
 PWMOutputState(PWM0_BASE, (PWM_OUT_0_BIT |PWM_OUT_1_BIT), true);
 PWMOutputState(PWM0_BASE, (PWM_OUT_2_BIT |PWM_OUT_3_BIT), true);
 PWMGenEnable(PWM0_BASE, PWM_GEN_0);
 PWMGenEnable(PWM0_BASE, PWM_GEN_1);
 
 motor_out(1000,1000,1000,1000);
 delay_Nms(3000);
}
油门程序
void motor_out(uint32_t motor1, uint32_t motor2, uint32_t motor3, uint32_t motor4)
{
 PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0,motor1);
 PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1,motor2);
 PWMPulseWidthSet(PWM0_BASE, PWM_OUT_2,motor3);
 PWMPulseWidthSet(PWM0_BASE, PWM_OUT_3,motor4);
}
main函数
int main()
{
 motor_init();
  while(1)
 {
  motor_out(1500,1500,1500,1500);
 }
}
求大神点拨