#include "driverlib.h"
#define TIMER_PERIOD 511
#define DUTY_CYCLE 350
void main(void)
{
//Stop WDT
WDT_A_hold(WDT_A_BASE);
//P2.0 as PWM output
GPIO_setAsPeripheralModuleFunctionOutputPin(
GPIO_PORT_P2,
GPIO_PIN0
);
//Generate PWM - Timer runs in Up mode
Timer_A_outputPWMParam param = {0};
param.clockSource = TIMER_A_CLOCKSOURCE_SMCLK;
param.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_1;
param.timerPeriod = TIMER_PERIOD;
param.compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_1;
param.compareOutputMode = TIMER_A_OUTPUTMODE_RESET_SET;
param.dutyCycle = DUTY_CYCLE;
Timer_A_outputPWM(TIMER_A1_BASE, ¶m);
//Enter LPM0
__bis_SR_register(LPM0_bits);
//For debugger
__no_operation();
}
|