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.

MSP430F6779A: Need help with Timers

Part Number: MSP430F6779A

ok, so I would try to explain and make it clear as much as possible. I am using MSP430F6779A and want to generate a PWM signal in pin 66(P4.7). Please refer page 12 of the datasheet for IC pin diagram and page 23 for the pin description. The pin is mapped to Timer TA3.0 with compare/ capture register TA3CCR0. From what I have learned, we need two CCR for generating PWM. We load the PWM cycle Period in TACCR0 register and the duty cycle set/reset time in the corresponding Timer mapped compare/caprture Register. For eg. At Pin 44 (P2.2 Timer mapped TA0.2), I am able to generate the desired PWM by putting PWM cycle Period in TA0CCR0 Register and the duty cycle period in TA0CCR2 register.  Let's say, TA0CCR0 = 255 & TA0CCR2  = 100. Then we assign OUTMOD_7 to the pin for Reset/Set operation. So initially, when the timer counts from 0 to TA0CCR2 value( 100 in this example) the pin is reset, but after it reaches TA0CCR2 value, the pin is set until it reaches TA0CCR0 value (255 in this example). This way we get the PWM.

But, here in P4.7 (TA3 Comapre/capture Register 0) I am unable to get the PWM. Suppose, we load the PWM cycle period in TA3CCR0 register, where are we supposed to load the duty cycle ON/OFF time period so the pin set/reset after certain time. Please help me with this as I think its not possible to get a PWM at that Pin. Please let me know if I am missing out something. Thanks in Advance! 

  • Hi Johnson,

    That's what I was saying. In the code example you sent, the TA2CCR0 (PWM cycle period) is loaded with 128 and TA2CCR1 (duty cycle on/off period) is set with 32. The TA2CCR1 is used and not other register (for example - TA2CCR2) because the pin 1.1 is mapped to TA2.1. So we load the value 32 in TA2CCR1. What I am concerned with here is the pin where I want to generate PWM (Pin 4.7) is mapped to TA3.0. So if I set TA3CCR0 with PWM cycle period, I am not left with any register where I could load duty cycle ON/OFF value. This was the code you sent.

    #include <msp430.h>
    
    void main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;               // Stop WDT
    
        // Setup P1.1 TA2.1
        P1DIR |= BIT1;                          // P1.1/TA2.1
        P1SEL0 |= BIT1;                          // Output TA1
    
        // Setup TA2
        TA2CCR0 = 128;                          // PWM Period/2
        TA2CCTL1 = OUTMOD_6;                    // CCR1 toggle/set
        TA2CCR1 = 32;                           // CCR1 PWM duty cycle
        TA2CTL = TASSEL_2 | MC_3 | TACLR;       // SMCLK, up-down mode, clear TAR
    
        __bis_SR_register(LPM0_bits);           // Enter LPM0
        __no_operation();                       // For debugger
    }

    For my application, I would change it little bit. 

    #include <msp430.h>
    
    void main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;               // Stop WDT
    
        // Setup P4.7 TA3.0
        P4DIR |= BIT7;                          // P4.17TA3.0
        P4SEL0 |= BIT7;                          // Output TA3
    
        // Setup TA3
        TA3CCR0 = 128;                          // PWM Period/2
        TA3CCTL0 = OUTMOD_6;                    // CCR0 toggle/set. 
        TA2CCR1 = 32;                           // what register do I use here? I can't use TA3CCR0. This will just change the PWM cycle period and not give me a PWM. I can't use TA3CCR1 or TA3CCR2 (don't know even it exist because there are only two CCR register in TA3 - CCR0 and CCR1) because they are not mapped to the P4.7 pin. 
       TA3CTL = TASSEL_2 | MC_3 | TACLR;       // SMCLK, up-down mode, clear TAR
    
        __bis_SR_register(LPM0_bits);           // Enter LPM0
        __no_operation();                       // For debugger
    }



    I am unable to understand what register I use at the point where I marked the background Red. Is there any way around to generate PWM at that Pin? Please let me know. Thanks
  • Please check the comment at the line where I used the background color. Thanks

  • Hi Harsh,

    TAX.0 cannot output PWM wave, it is a register used to control the frequency of PWM wave.

    Best Regards

    Johnson

**Attention** This is a public forum