This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
ROM_ 的函数都包含在#include "driverlib/rom.h" 头文件中
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/pwm.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "utils/uartstdio.h"
#ifdef DEBUG
void
__error__(char *pcFilename, unsigned long ulLine)
{
}
#endif
//*****************************************************************************
//
// This example demonstrates how to setup the PWM block to generate signals.
//
//*****************************************************************************
int
main(void)
{
unsigned long ulPeriod;
//
// Set the clocking to run directly from the crystal.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
ROM_SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
//
// Initialize the UART.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTStdioInit(0);
//
// Tell the user what is happening.
//
UARTprintf("\033[2JGenerating PWM on PD0 and PD1\n");
//
// Enable the peripherals used by this example.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
//
// Set GPIO D0 and D1 as PWM pins. They are used to output the PWM0 and
// PWM1 signals.
//
GPIOPinConfigure(GPIO_PE6_PWM4);
GPIOPinConfigure(GPIO_PE1_PWM5);
ROM_GPIOPinTypePWM(GPIO_PORTE_BASE, GPIO_PIN_1 | GPIO_PIN_6);
//
// Compute the PWM period based on the system clock.
//
ulPeriod = ROM_SysCtlClockGet() / 440;
//
// Set the PWM period to 440 (A) Hz.
//
ROM_PWMGenConfigure(PWM0_BASE, PWM_GEN_0,
PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
ROM_PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, ulPeriod);
//
// Set PWM0 to a duty cycle of 25% and PWM1 to a duty cycle of 75%.
//
ROM_PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, ulPeriod / 4);
ROM_PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, (ulPeriod * 3) / 4);
//
// Enable the PWM0 and PWM1 output signals.
//
ROM_PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, true);
//
// Enable the PWM generator.
//
ROM_PWMGenEnable(PWM0_BASE, PWM_GEN_0);
//
// Loop forever while the PWM signals are generated.
//
while(1)
{
}
}一直是这样不知道什么情况,该包含的文件我都包含了,这个程序是历程上的,导入能正确运行但是自己建立一个,把.C的程序复制进来就会出错,上边是我所有的配置