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.

MSP430FR2311 用TB1不能输出PWM

Other Parts Discussed in Thread: MSP430FR2311

Hi,

我用MSP430FR2311 输出pwm,TB0输出pwm正常;由于pcb板子已经步好了,只能用TB1.2(P2.1),但是不能输出pwm,code如下所示:

#include "driverlib.h"

#define TIMER_PERIOD 511
#define DUTY_CYCLE 383

void main(void)
{
//Stop WDT 2k、364、481
WDT_A_hold(WDT_A_BASE);

//P1.6 as PWM output
GPIO_setAsPeripheralModuleFunctionOutputPin(
GPIO_PORT_P2,
GPIO_PIN1,
GPIO_SECONDARY_MODULE_FUNCTION
);

//Disable the GPIO power-on default high-impedance mode to activate
//previously configured port settings
PMM_unlockLPM5();

//Generate PWM - Timer runs in Up mode
Timer_B_outputPWMParam param = {0};
param.clockSource = TIMER_B_CLOCKSOURCE_SMCLK;
param.clockSourceDivider = TIMER_B_CLOCKSOURCE_DIVIDER_1;
param.timerPeriod = TIMER_PERIOD;
param.compareRegister = TIMER_B_CAPTURECOMPARE_REGISTER_2;
param.compareOutputMode = TIMER_B_OUTPUTMODE_RESET_SET;
param.dutyCycle = DUTY_CYCLE;
Timer_B_outputPWM(TIMER_B1_BASE, &param);

//Enter LPM0
__bis_SR_register(LPM0_bits);

//For debugger
__no_operation();
}

谢谢!