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.

我想用msp430的timerB调pwm波形,可是怎么也出不来

我想用msp430的timerB调pwm波形,可是怎么也出不来?求解??
用timerA能完美实现,但timerB却不行,即便是TI的例程也不行,哪位大神给解释一下啊,谢谢了

#include  <msp430x14x.h>

void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  P4DIR |= 0x7e;                            // P4.1 - P4.6 output
  P4SEL |= 0x7e;                            // P4.1 - P4.6 TBx options
  TBCCR0 = 512-1;                           // PWM Period
  TBCCTL1 = OUTMOD_7;                       // CCR1 reset/set
  TBCCR1 = 384;                             // CCR1 PWM duty cycle
  TBCCTL2 = OUTMOD_7;
  TBCCR2 = 128;
  TBCCTL3 = OUTMOD_7;
  TBCCR3 = 64;
  TBCCTL4 = OUTMOD_7;
  TBCCR4 = 32;
  TBCCTL5 = OUTMOD_7;
  TBCCR5 = 16;
  TBCCTL6 = OUTMOD_7;
  TBCCR6 = 8;
  TBCTL = TBSSEL_2 + MC_1;                  // SMCLK, up mode

  _BIS_SR(CPUOFF);                          // Enter LPM0
}

另外,发现介绍timerB的资料也较少,有什么好资料吗?给推荐一下

  • 最好的资料就是,MSP430X1XX Family User's Guide

    这个例程是可以工作的,单步检查一下Timer_B counter有没有变化

  • 楼主你好!

    1、timer B的资料很多,网上也有F1XX系列的中文user guide;

    2、试试这个历程,如果没有反应,就是硬件问题

    #include <msp430.h>

    int main(void)
    {
    WDTCTL = WDTPW + WDTHOLD; // Stop WDT
    P4DIR |= 0x06; // P4.1 and P4.2 output
    P4SEL |= 0x06; // P4.2 and P4.2 TB1/2 otions
    TBCCR0 = 128; // PWM Period/2
    TBCCTL1 = OUTMOD_6; // CCR1 toggle/set
    TBCCR1 = 32; // CCR1 PWM duty cycle
    TBCCTL2 = OUTMOD_6; // CCR2 toggle/set
    TBCCR2 = 96; // CCR2 PWM duty cycle
    TBCTL = TBSSEL_2 + MC_3; // SMCLK, up-down mode

    while(1);
    }

  • 谢谢,我试试