已解决
#include
#include
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/rom.h"
#include "driverlib/gpio.h"
#include "driverlib/pwm.h"
#include "driverlib/fpu.h"
#include "driverlib/pin_map.h"
int main (void)
{
//设置系统时钟为80MHz
SysCtlClockSet(SYSCTL_SYSDIV_2_5 |SYSCTL_USE_PLL|SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);//使能PWM0模块
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);//使能PWM0输出所在GPIO
SysCtlPWMClockSet(SYSCTL_PWMDIV_1); // PWM时钟配置:不分频
GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_4);
GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_5);
GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6);
GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7);
GPIOPinConfigure(GPIO_PB6_M0PWM0); //#define GPIO_PB6_M0PWM0 0x00011804
GPIOPinConfigure(GPIO_PB7_M0PWM1); //#define GPIO_PB7_M0PWM1 0x00011C04
GPIOPinConfigure(GPIO_PB4_M0PWM2); //#define GPIO_PB4_M0PWM2 0x00011804
GPIOPinConfigure(GPIO_PB5_M0PWM3); //#define GPIO_PB5_M0PWM3 0x00011C04
//配置PWM发生器0:加减计数,不同步
PWMGenConfigure(PWM0_BASE,PWM_GEN_0,PWM_GEN_MODE_UP_DOWN| PWM_GEN_MODE_NO_SYNC);
//设置PWM发生器0的频率,时钟频率/PWM分频数/n,80M/1/800=100KHZ
PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 1600);
//配置PWM发生器0:加减计数,不同步
PWMGenConfigure(PWM0_BASE,PWM_GEN_1,PWM_GEN_MODE_UP_DOWN| PWM_GEN_MODE_NO_SYNC);
//设置PWM发生器0的频率,时钟频率/PWM分频数/n,80M/1/800=100KHZ
PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, 1600);
//设置PWM01输出的脉冲宽度
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 400);//50%占空比
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, 300);//
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_2, 400);//
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_3, 400);//
//使能PWM0输出
PWMOutputState(PWM0_BASE, (PWM_OUT_0_BIT |PWM_OUT_1_BIT|PWM_OUT_2_BIT|PWM_OUT_3_BIT), true);
//使能PWM发生器
PWMGenEnable(PWM0_BASE, PWM_GEN_0);
PWMGenEnable(PWM0_BASE, PWM_GEN_1);
while(1);
}
#include
#include
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/rom.h"
#include "driverlib/gpio.h"
#include "driverlib/pwm.h"
#include "driverlib/fpu.h"
#include "driverlib/pin_map.h"
int main (void)
{
//使能FPU
FPUEnable();
FPULazyStackingEnable();
//设置系统时钟为80MHz
SysCtlClockSet(SYSCTL_SYSDIV_2_5 |SYSCTL_USE_PLL|SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);//使能PWM0模块
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);//使能PWM0输出所在GPIO
GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_4);
GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_5);
GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6);
GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7);
//配置PH0/PH1为PWM功能
GPIOPinConfigure(GPIO_PB6_M0PWM0); //#define GPIO_PB6_M0PWM0 0x00011804
GPIOPinConfigure(GPIO_PB7_M0PWM1); //#define GPIO_PB7_M0PWM1 0x00011C04
GPIOPinConfigure(GPIO_PB4_M0PWM2); //#define GPIO_PB4_M0PWM2 0x00011804
GPIOPinConfigure(GPIO_PB5_M0PWM3); //#define GPIO_PB5_M0PWM3 0x00011C04
SysCtlPWMClockSet(SYSCTL_PWMDIV_1); // PWM时钟配置:不分频
//配置PWM发生器0:加减计数,不同步
PWMGenConfigure(PWM0_BASE,PWM_GEN_0,PWM_GEN_MODE_UP_DOWN| PWM_GEN_MODE_NO_SYNC);
//设置PWM发生器0的频率,时钟频率/PWM分频数/n,80M/1/800=100KHZ
PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 800);
//设置PWM01输出的脉冲宽度
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 400);//50%占空比
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, 300);//
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_2, 400);//
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_3, 400);//
//使能PWM0输出
PWMOutputState(PWM0_BASE, (PWM_OUT_0_BIT |PWM_OUT_1_BIT|PWM_OUT_2_BIT|PWM_OUT_3_BIT), true);
//使能PWM发生器
PWMGenEnable(PWM0_BASE, PWM_GEN_0);
while(1);
}
PWM0,PWM1正常 PWM2,PWM3没有输出 是为什么 能帮我看看吗