EK-TM4C123GXL: 用CCS編寫一個PWM信號程式, 燒錄後第一次執行OK, 但是reset或power off/on後就沒有輸出了 Why?

Part Number: EK-TM4C123GXL
Other Parts Discussed in Thread: TM4C123GH6PM

用CCS編寫一個PWM信號程式, 燒錄後第一次執行OK, 但是reset或power off/on後就沒有輸出了 Why?

程式如下:

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_GPIO.h"
#include "driverlib/sysctl.h"
#include "driverlib/pin_map.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "inc/tm4c123gh6pm.h"
#include "driverlib/pwm.h"

/**
* hello.c
*/
int main(void)
{
/*Step_1 Clock Setting*/

SysCtlClockSet(SYSCTL_XTAL_16MHZ|SYSCTL_USE_PLL|SYSCTL_SYSDIV_64|SYSCTL_OSC_MAIN);
SysCtlPWMClockSet(SYSCTL_PWMDIV_64);


/*Step_2 Enables GPIO and PWM Modules*/
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // Select Port F
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1); // Select PWM1
HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= 0x01;

/*Step_3 Configure PWM Module*/
//This function configures to use a specific pin on the WPM mdoule.
//GPIOPinConfigure(GPIO_PF0_M1PWM4);
//GPIOPinConfigure(GPIO_PF1_M1PWM5);
GPIOPinConfigure(GPIO_PF2_M1PWM6);
GPIOPinConfigure(GPIO_PF3_M1PWM7);

// The character | is a logical 'or'.
// This function sets the functionality of GPIO Pin within GPIO module.
//GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_0 |GPIO_PIN_1 |GPIO_PIN_2 |GPIO_PIN_3);
GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_2 |GPIO_PIN_3);
//This PWM generation function creates the pulses needed for PWM module.
//PWM_GEN_2 is the generator for module tied to PWM pins 4 and 5. PWM_GEN_3 is for
//pins 6 and 7.
//PWM_GEN_MODE_NO_SYNC is used so that the generator gives immediate updates rather
//than synchronizing with the clock to update.
//PWMGenConfigure(PWM1_BASE, PWM_GEN_2, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
PWMGenConfigure(PWM1_BASE, PWM_GEN_3, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);

//400 would be 400 clock ticks as a period.
//PWMGenPeriodSet(PWM1_BASE, PWM_GEN_2, 400);
PWMGenPeriodSet(PWM1_BASE, PWM_GEN_3, 48828);

//300 is the clock ticks of the width of the pulse. 300 would be 75% duty cycle for
//400 clock ticks period.
//PWMPulseWidthSet(PWM1_BASE, PWM_OUT_4, 10);
//PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, 10);
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_6, 49);
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_7, 49);

//PWMGenEnable(PWM1_BASE, PWM_GEN_2);
PWMGenEnable(PWM1_BASE, PWM_GEN_3);

//PWMOutputState(PWM1_BASE,(PWM_OUT_4_BIT | PWM_OUT_5_BIT |PWM_OUT_6_BIT |PWM_OUT_7_BIT), true);
PWMOutputState(PWM1_BASE,(PWM_OUT_6_BIT |PWM_OUT_7_BIT), true);

//GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);

while(1)
{
//GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x08);
//SysCtlDelay(2000000);
// Turn on the LED
//GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x00);
// Delay for a bit
//SysCtlDelay(2000000);

}

return 0;
}