帮忙看看程序为什么出不来PWM波

2019-03-24 13:40发布


程序可以编译,没有错误,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)
    {    }    
       }
此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
4条回答
Study_Stellaris
2019-03-25 04:12
 精彩回答 2  元偷偷看……0人看过

一周热门 更多>

相关问题

    相关文章