在手工焊接板的测试上,遇到了一些问题,希望和各位感兴趣的探讨一下,问题如下:
我们用的芯片是LM3S3748,但是pwm不输出波形,当把它用作GPIO时,就可以输出高低电平,我想知道为什么,更想知道解决方法。可以QQ联系:421476865
int main(void)
{
unsigned long ulPeriod;
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
ROM_SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
ROM_GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_1);
ROM_GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_1,
GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
ulPeriod = ROM_SysCtlClockGet() / 8000;
ROM_PWMGenConfigure(PWM_BASE, PWM_GEN_0,
PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);//PWM_GEN_MODE_UP_DOWN
ROM_PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, ulPeriod);
ROM_PWMPulseWidthSet(PWM_BASE, PWM_OUT_0, ((ulPeriod * 8) / 10));
ROM_PWMPulseWidthSet(PWM_BASE, PWM_OUT_1, ((ulPeriod * 2) / 10));
ROM_PWMOutputState(PWM_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, true);
ROM_PWMGenEnable(PWM_BASE, PWM_GEN_0);
unsigned short w_Dat = 0;
while(1)
{
SysCtlDelay(8000);
if(w_Dat < 1000)w_Dat++;
else w_Dat = 0;
ROM_PWMPulseWidthSet(PWM_BASE, PWM_OUT_0,w_Dat);
}
}