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.

MSP430G2553: Output control of timerA

Part Number: MSP430G2553

Hello,

and thanks for giving this question a read. In slau144, on page there's an OUT2 Signal. I was under the impression that every CCR register will have a corresponding output unit, which can output to a pin. At least, for the MSP430G2553's.



I looked at the pins to see where these might be and this seemed to be confirmed


So now I type up some code to give me 2 different duty cycles, with no help from the CPU

#include <msp430.h> 

/**
 * main.c
 */
int main(void)
{
	WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer
	

    BCSCTL1 = CALBC1_16MHZ;
    DCOCTL = CALDCO_16MHZ;

	// -------------------------- Pin Setup ------------------------
	P1DIR |= BIT2;
	P1SEL |= BIT2;

	P1DIR |= BIT5;
    P1SEL |= BIT5;
	//---------------------------- TIMER A Setup --------------------
	TACCR0 = 1023;
	TACCR1 = 127;
	TACCR2 = 512;

	TACCTL1 = OUTMOD_7;
	TA0CTL = TASSEL_2 + MC_1+ID_0;
	while(1){}

	return 0;
	}


GOOD NEWS! I see a pulse with the intended duty cycle on P1.2, bit P1.5  gives me nothing. I know i can get this behavior working with an interrupt, but I'd rather not use the CPU.

Anyone have any tips? 

Thanks for looking this over.

~Triston

  • To get output based on TACCR2 (i.e. TA0CCR2), you would need pin function TA0.2, which isn't available (P3.6) on the 20-pin package.

    You could use TA1, which provides TA1.2 (P2.4 or P2.5) along with TA1.1 (P2.1 or P2.2). You would also have to set TA1CCTL2=OUTMOD_7.

  • Well, that clears things up. So just to make sure

    Pin P1.1 and P1.5 can be controlled by CCR0 (TA0.0), and
    Pin P1.2 is controlled by CCR1?

     CCR0 isn't really functional for UP mode, so I only have P1.2 for output - right?

    However, on TA1 I have 3 counter compare registers, so I can use TA1.1 and TA1.2.

    Sir, I altered my code to use TA1 and it works. Thank you for your assistance!

    #include <msp430.h> 
    
    /**
     * main.c
     */
    int main(void)
    {
    	WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer
    	
    
        BCSCTL1 = CALBC1_16MHZ;
        DCOCTL = CALDCO_16MHZ;
    
    	// -------------------------- Pin Setup ------------------------
    	//P1DIR |= BIT2;
    	//P1SEL |= BIT2;
    
    	P2DIR |= BIT1;
        P2SEL |= BIT1;
    
        P2DIR |= BIT4;
        P2SEL |= BIT4;
    	//---------------------------- TIMER A Setup --------------------
    	TA1CCR0 = 1023;
    	TA1CCR1 = 512;
    	TA1CCR2 = 128;
    
    	TA1CCTL2 = OUTMOD_7;
    	TA1CCTL1 = OUTMOD_7;
    
    	TA1CTL = TASSEL_2 + MC_1+ID_0;
    	while(1){}
    
    	return 0;
    }



**Attention** This is a public forum