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.

[参考译文] MSP430F5419A:MSP430 DriverLib:如何在多个通道上输出 PWM?

Guru**** 2535650 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/921298/msp430f5419a-msp430-driverlib-how-to-output-pwm-on-multiple-channels

器件型号:MSP430F5419A
主题中讨论的其他器件:MSP430WARE

您好!

我有一个 RGB LED 连接到 用于红色的 P4.1/TB0.1、用于绿色的 P4.2/TB0.2和用于绿色的 P4.3/TB0.3。 我已成功使用 Timer_B_outputPWM 在一个输出上输出 PWM、但如何配置 Timer B 在所有三个通道上输出 PWM。 初始化代码:

void halTimerInitRgbLedPwm()

rgbLedPwmParam.clockSource = Timer_B_CLOCKSOURCE_SMCLK;//4Mhz
rgbLedPwmParam.clockSourceDivider = TIMER_B_CLOCKSOURCE_divider;//TACLK = 4MHz
rgbLedPwmParam.timerPeriod = RGB_LED_PWM_TIMER_PERIOD;
rgbLedPwmParam.compareRegister = TIMER_B_CAPTURECMPARE 寄存器_1;
rgbLedPwmParam.compareOutputMode =定时器_B_OUTPUTMODE_RESET_SET;
rgbLedPwmParam.dutyCycle = 0;
Timer_B_outputPWM (timer_B0_BASE、&rgbLedPwmParam);

配置完成后、我意识到我可以使用 Timer_B_setCompareValue ()为给定的捕捉/比较寄存器设置占空比、但如何将所有三个输出配置为 PWM?

谢谢、

Derek

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Derek:

    Timer_B 有7个捕捉/比较寄存器。 它们中的每一个都可用于生成 PWM 输出、这与使用 register_1生成 PWM 输出的方式类似。

    您可以在 MSP430WARE (https://www.ti.com/tool/MSPWARE)或 MSP430驱动程序库(https://www.ti.com/tool/MSPDRIVERLIB)中看到代码示例"timer_b_ex3_PWM"。

    我在这里包括相关部分:

    --------------------------------------------------

    //初始化比较模式以生成 PWM1
    Timer_B_initCompareModeParam initComp1Param ={0};
    initComp1Param.compareRegister = TIMER_B_CAPTURECMPARE 寄存器_1;
    initComp1Param.compareInterruptEnable = TIMER_B_CAPTURECMPARE INTERRUPT_DISABLE;
    initComp1Param.compareOutputMode =定时器_B_OUTPUTMODE_RESET_SET;
    initComp1Param.compareValue = 383;
    Timer_B_initCompareMode (timer_B0_BASE、&initComp1Param);

    //初始化比较模式以生成 PWM2
    Timer_B_initCompareModeParam initComp2Param ={0};
    initComp2Param.compareRegister = TIMER_B_CAPTURECMPARE 寄存器_2;
    initComp2Param.compareInterruptEnable = TIMER_B_CAPTURECMPARE INTERRUPT_DISABLE;
    initComp2Param.compareOutputMode =定时器_B_OUTPUTMODE_RESET_SET;
    initComp2Param.compareValue = 128;
    Timer_B_initCompareMode (timer_B0_BASE、&initComp2Param);

    --------------------------------------------------

    Srinivas