我用的是LM4F231H5QR芯片,PG4产生PWM信号(M0PWM4) 但是不知道为什么就是没有输出
SysCtlPWMClockSet(SYSCTL_PWMDIV_1); //66.6M
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
GPIOPinConfigure(GPIO_PG4_M0PWM4);
GPIOPinTypePWM(GPIO_PORTG_BASE, GPIO_PIN_4);
PWMGenConfigure(PWM_BASE, PWM_GEN_0,PWM_GEN_MODE_DOWN |PWM_GEN_MODE_NO_SYNC);
PWMGenPeriodSet(PWM_BASE, PWM_GEN_0,64000);
PWMPulseWidthSet(PWM_BASE,PWM_OUT_4,640); 或者PWMPulseWidthSet(PWM_BASE,PWM_OUT_0,640);都试过
PWMOutputState(PWM_BASE,PWM_OUT_4_BIT,1);
PWMGenEnable(PWM_BASE, PWM_GEN_0);
就是没有PWM输出,请指教
step by step:
楼主尝试调整一下初始化的顺序试试看:
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
SysCtlPWMClockSet(SYSCTL_PWMDIV_1); //66.6M
……
Wellin Zhang:
初始化的过程中,如果使用的是PWM0模块,PWM_BASE的基址应该是PWM0_BASE