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.

CCS/MSP430FR5857: Timer PWM when stopped should give high on pin.

Part Number: MSP430FR5857

Tool/software: Code Composer Studio

#include <msp430.h>
#include <stdint.h>

int main(void)
{


    WDTCTL = WDTPW | WDTHOLD;               // Stop WDT

    // Configure GPIO
    P1DIR |= BIT0 | BIT1;                   // P1.0 and P1.1 output
    P1SEL0 |= BIT0 | BIT1;                  // P1.0 and P1.1 options select
    P1SEL1 &= ~(BIT0 | BIT1);
    PJSEL0 |= BIT4 | BIT5;

    // Disable the GPIO power-on default high-impedance mode to activate
    // previously configured port settings
    PM5CTL0 &= ~LOCKLPM5;

    /* operation beyond 8MHz _before_ configuring the clock system.*/
    FRCTL0 = FRCTLPW | NWAITS_1;

    /* Clock System Setup*/
    CSCTL0_H = CSKEY >> 8;                    /* Unlock CS registers*/
    CSCTL1 = DCORSEL | DCOFSEL_4;             /* Set DCO to 16MHz*/
    CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK; // Set ACLK = XT1; MCLK = DCO
    CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;   // Set all dividers
    CSCTL4 &= ~LFXTOFF;
    do
    {
        CSCTL5 &= ~LFXTOFFG;                // Clear XT1 fault flag
        SFRIFG1 &= ~OFIFG;
    } while (SFRIFG1 & OFIFG);              // Test oscillator fault flag
    CSCTL0_H = 0;                           // Lock CS registers

    // Configure Timer0_A
    TA0CTL |=TACLR;
    TA0CCR0 = 16000-1;                        // PWM Period
    TA0CCTL1 = OUTMOD_1|CLLD_1;                    // CCR1 reset/set
    TA0CCR1 = 8000;                           // CCR1 PWM duty cycle
    TA0CTL = TASSEL__SMCLK | MC__UP; // ACLK, up mode, clear TAR

    __bis_SR_register(LPM3_bits);           // Enter LPM3
    __no_operation();                       // For debugger
}

This is the code I am thinking of basing the next code I am writing.

What I want to know is if when I stop Timer A0 by writing

TA0CTL| = MC__STOP;

will the output at TA0.1 be high or low or will it depend on what level the PWM is on.

I want to write code so that it stays high whenever TimerA0 is stopped.

Thank you in advance.

Viswanath.

  • Hi Viswanath,
    The output at TA0.1 be high or low or will it depend on what level the PWM is on.
    You can check the counting number in CCR1. If it's under 8000, than you can stop the timer.

    Best regards,
    Cash Hao

**Attention** This is a public forum