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.

multiple-PWM on g2553 (based on slaa513) does not seem to work



Hi,


I'm having problems with multiple-PWM signals on my G2553, to be more specific, only with timer A1 and TA1CCR2.

The entire thing is based on slaa513 and i don't see the point where i'm making a mistake.

I'm looking at it for a few days now and i don't get it to work by trying different things in the code.

The behaviour that i see is that i get interrupts on Timer A1, also i get them for TA1CCR2 (TA1IV -> case 2), but it does not detect if the pin is high (TA1CCTL2 & CCI ).

When looking at the pin with a scope, i'll see that the pin is high and low, 60us high and 60us low (so a duty-cycle of 50%).

So it looks like that (TA1CCTL2 & CCI) is always false, so the code "TA1CCR2 += 160;" is never executed (also placed breakpoints here, never executed).

Fot the other counters TA1CCR0 and TA1CCR1 it is working as expected, the code is very simular.

Below the simplified code i'm using, which still contains the weird behavior.

Also disabled the other counters and the problem is persitent.

Any help is appeciated.

#include <msp430.h>

void main(void)
{
    WDTCTL = WDTPW + WDTHOLD;    // Stop watchdog timer

    if (CALBC1_8MHZ ==0xFF || CALDCO_8MHZ == 0xFF)  // If calibration data is erased
    {
       while(1);                    // TRAP
    }

    BCSCTL1 = CALBC1_8MHZ;                  // Set range
    DCOCTL = CALDCO_8MHZ;                   // Set DCO step + modulation
    BCSCTL2 |= SELM_0 + DIVM_0;             // MCLK = DCOCLK
    BCSCTL3 |= LFXT1S_0 + XCAP_3 + DIVA_0;  // LFXT1 = 32768 crystal

    __delay_cycles(55000);   // let crystal stabilize

    IFG1 &= ~OFIFG;                  // Clear OSCFault flag
    if (IFG1 & OFIFG)             // If OSCFault is still on
    {
           while(1);                  // TRAP
    }

    P1SEL = 0x00;  // no specific register selected, all pins are GPIO-pins (digital)
    P1SEL2 = 0x00; // default I/O function is selected
    P2SEL2 = 0x00; // default I/O function is selected
    P1DIR = 0x00;  // default all output
    P1OUT = 0x00;  // default all low
    P2DIR = 0x00;  // default all output
    P2OUT = 0x00;  // default all low

    P1REN = 0x00;  // default no pullup/pulldown resistors
    P2REN = 0x00;  // default no pullup/pulldown resistor

//    TA1CCTL0 = OUTMOD_4 + CCIE;               /* Timer1_A3 Capture/Compare Control 0 */
//    TA1CCTL1 = OUTMOD_4 + CCIE;               /* Timer1_A3 Capture/Compare Control 1 */
    TA1CCTL2 = OUTMOD_4 + CCIE;                 /* Timer1_A3 Capture/Compare Control 2 */
    TA1CTL = TASSEL_2 +  MC_2 + ID_3 + TAIE;    /* Timer1_A3 Control, SMCLK@8MHZ divide by 8 => 1MHz */
    
    P2DIR |= (BIT0|BIT1|BIT5);   // BIT0 on P2.0; BIT1 on P2.1; BIT5 on P2.5
    P2SEL |= (BIT0|BIT1|BIT5);   // primary register selected
    P2SEL2 &= ~(BIT0|BIT1|BIT5); // make sure they are 0

    __enable_interrupt();

    while (1)
    {
    }
}

//#pragma vector=TIMER1_A0_VECTOR
//__interrupt void Timer_A0 (void)
//{
//       // P2.0
//       if(TA1CCTL0 & CCI) //If output currently high
//       {
//          TA1CCR0 += 400; // % high
//       }
//       else
//       {
//          TA1CCR0 += 100; // low for rest of the period
//       }
//}

#pragma vector=TIMER1_A1_VECTOR
__interrupt void Timer_A1(void)
{
   switch( TA1IV )
   {
//   //P2.1
//   case 2:
//      if (TA1CCTL1 & CCI)    // If output currently high
//      {
//          TA1CCR1 +=10;
//      }
//      else
//      {
//          TA1CCR1 +=50;
//      }
//      break;
    //P2.5
   case 4:
      if ( TA1CCTL2 & CCI )    // If output currently high
      {
//-->> CODE NEVER GETS HERE?
          TA1CCR2 += 160;
      }
      else
      {
          TA1CCR2 += 60;
      }
      break;
   default: break;
   }
}

  • + TAIE;
    to tell that you want overflow IRQs but I don't see you have a case for it
    case TA1IV_TAIFG: //Vector TAIFG


    And should it not be:
    switch(__even_in_range(TA1IV,0x0A))

  • Hi Tony,

    I also tested it without "+TAIE", same result.

    I added this statement because in the slaa513 they also describe it, i already tried a lot of different combinations of small changes in the configuration......i think i'm getting "code-blinded" (so i need some help from people that know this stuff, my girlfriend doesn't understand this stuff ;-)

    The problem is not with the interrupts, because i get the interrupts.

    Also the other timers (TA1CCR0 and TA1CCR1) are working, at this point it's really weird that TA1CCR2 is not working.

  • Changed the output-pin from Timer1_A3.TA2 from pin 2.5 to pin 2.4, now it is working.
    It looks like the CCI register in TACCTL2 is not set when pin 2.5 is chosen.
    Do is miss something in the configuration, or can i configure that the value from pin 2.5 is set into CCI?
  • Looks like i found it (i'm not 100% sure).
    But it looks like you'll have to select what the input is for the CCI register.
    So when using port 2.5 (probably the second (or B) on TA1.2) also set CCIS_1

    TA1CCTL2 = OUTMOD_4 + CCIE + CCIS_1;

    CCIS_0 (default) is for pin 2.4 (or A), so the timer output TA1.2.
    So the CCISx is not only used for "capture" but does also something for "compare".
  • I think you're right, setting TA1CCTL2.CCIS_1 should fix this problem in your case.

    It's fortunate you weren't using TA0; that has no CCI2A input on 20 pin 2553s, and CCI2B is tied to PinOsc.
  • Hi KG_B,

    Thank you so much for pointing this out, and sorry for all of the difficulties. I wrote and tested the app note for G2452 before G2553 was widespread - it seems that with the additional timer connections and pins on the G2553 these problems can appear if you do not explicitly set the CCIS_x setting to be careful of the internal connections. I will work to update the app note and code to make mention of this and to include setting CCIS_x setting as best practice to ensure correct operation. Thanks again for bringing this to my attention.

    Regards,

    Katie

**Attention** This is a public forum