TI中文支持网
TI专业的中文技术问题搜集分享网站

MSP430FR2311 用TB1不能输出PWM

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();
}

谢谢!

yudong du:

知道了,是功能引脚没有配置好,如下配置就ok了。

GPIO_setAsPeripheralModuleFunctionOutputPin( GPIO_PORT_P2, GPIO_PIN1, GPIO_PRIMARY_MODULE_FUNCTION );

yudong du:

功能引脚配置问题,已解决!

灰小子:

回复 yudong du:

能者自答,赞!

Outman J:

GPIO_setAsPeripheralModuleFunctionOutputPin()第三个参数代表着对pxsel的配置,前面两个参数具体代表着什么含义呢?

Outman J:

回复 Outman J:

端口 +管脚酱紫

赞(0)
未经允许不得转载:TI中文支持网 » MSP430FR2311 用TB1不能输出PWM
分享到: 更多 (0)