程序可以编译,没有错误,PG3口,PWMGEN0,PWM1,就是出不来PWM波,不知道错误在哪儿,向各位大侠求助,谢谢!
#include "inc/lm3s2b93.h"
#include "inc/hw_gpio.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/pwm.h"
int
main(void)
{ unsigned long ulPeriod;
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_12MHZ);
SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_7);
GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_7, 0x00);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM);
GPIOPinTypePWM(GPIO_PORTG_BASE, GPIO_PIN_3);
ulPeriod = SysCtlClockGet() / 440;
PWMGenConfigure(PWM_BASE, PWM_GEN_0,
PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, ulPeriod);
PWMPulseWidthSet(PWM_BASE, PWM_OUT_1, ulPeriod / 2);
PWMOutputState(PWM_BASE, PWM_OUT_1_BIT, true );
PWMGenEnable(PWM_BASE, PWM_GEN_0);
while(1)
{
}
}
此帖出自
小平头技术问答
看一下所在的脚是不是和 GEN0 对应的。
一周热门 更多>