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.

Compiler: MSP430f149 issue with pulse pack

Other Parts Discussed in Thread: MSP430F149

Tool/software: TI C/C++ Compiler

MSP430f149 issue with pulse pack

Dear friends,

Please help me with this issue: I've tried to get pulse pack from 1.5 pin MSP430f149.

I need to generate pulse packs with frequency: 40 000 Hz from TA0. But I can't do it. I get only pulses. 

How to make the delay of the timer? I need it for ultrasonic receiver/sender. Pulse pack need to excite the ultrasonic sensor and pause - to receive the signal input.

If I use only pin 1.5(TA0)  may I use CCR1 to make the PWM?

How to make the PWM? 

Please, anybody, help me with this issue.

void timerA_PWM()
{

TACCR0=18;

TACCR1=10;

TACCTL1=OUTMOD_7;

TACTL=TASSEL_2 +MC_1;
}

void timerA_pause()
{

TACCR0 = 12000-1;

TACCTL0 = CCIE;

TACTL = MC_1|ID_3|TASSEL_1|TACLR;
}


#pragma vector = TIMERA0_VECTOR
__interrupt void TIMERA0_VECTOR_ISR(void)
{

timerA_PWM();

_delay_cycles(1000);

timerA_pause();
}

  • P1.5 connects to CCR0 of TA0, this can only control the timer's period. P1.6/CCR1 or P1.7/CCR2 must be used to output a PWM. You should not be controlling TA0 inside of the interrupt, and the only way to stop a timer is to clear the MC bits from the TACTL register. If you want to pause the timer output then you need to clear TACCR1 and TACCTL1. Please further review the timer code examples provided by TI.

    Regards,
    Ryan
  • Dear Ryan,

    Thank you for your prompt reply.

    I don't understand, if I want to send pulse sequences with 40 000 Hz. Which pins I should use? May I use only one output - 1.5pin for this task?

    And where I can find the example of the code? My example is not correct?

    Please help me)
  • Nastya,

    Timer period is determined by CCR0, whereas the duty cycle of a given output is selected with CCR1/CCR2. Keep in mind that the default MCLK/SMCLK frequency is from the DCO at ~800 kHz. ACLK should be provided by LFXT1CLK through an external 32 kHz crystal.

    www.ti.com/.../slac015

    Regards,
    Ryan
  • Dear Ryan,

    Could you help me with pulse pack.
    How to make only 5 pulses and then make a delay with Timer A?

    I need 11111_________________11111_________
    How I can do it with interrupt?
    I didn't find the example in slac015s.
  • Nastya,

    Use the CCR0 interrupt to count the number of periods, after counting to five then turn off the output accordingly and readjust the value of CCR0 to the desired delay, then on the next interrupt change CCR0 back to the pulse period and re-start the output. The timer examples provided will help get you started.

    Regards,
    Ryan
  • Dear Ryan,

    Unfortunately, but I can't understand how to do it. Maybe you have more examples to make this task?

    Thank you in Advance!
  • The known timer examples have been provided, you will need to debug your program from here and do some more research to fully understand the MSP430's timer capabilities and application code.

    Regards,
    Ryan
  • Dear Ryan,

    Please could you explain to me why I cant go into interrupt?

    void timerA_pause()
    {

    TACCR0 = 36564;
    TACCTL0 = CCIE;
    TACTL = MC_1|TASSEL_2|TACLR;
    }

    void timerA_PWM()
    {
    TACCR0= 18;
    TACCR1=7;
    TACCTL1=OUTMOD_7;
    TACTL |= TASSEL_2+MC_1;
    }

    #pragma vector = TIMERA0_VECTOR
    __interrupt void TIMERA0_VECTOR_ISR(void)
    {

    timerA_PWM();

    _delay_cycles(5000);

    timerA_pause();
    }
    void main(void)
    {
    WDTCTL=WDTPW+WDTHOLD;
    P1DIR|=BIT6;
    P1SEL|=BIT6;

    timerA_pause();
    _BIS_SR(LPM0_bits+GIE);
    }
  • I imagine the interrupt is entered once but you are having trouble with it afterwards.  You should not be operating for so long while inside of the ISR.  Below are some recommended changes (untested):

    void timerA_pause()
    {
    
    TACCR0 = 36564;
    TACCTL0 = CCIE;
    TACCTL1&=~OUTMOD_7;
    TACTL = MC_1|TASSEL_2|TACLR;
    }
    
    void timerA_PWM()
    {
    TACCTL0&=~CCIE;
    TACCR0= 18;
    TACCR1=7; 
    TACCTL1=OUTMOD_7;
    TACTL |=TACLR;
    }
    
    #pragma vector = TIMERA0_VECTOR
    __interrupt void TIMERA0_VECTOR_ISR(void)
    {
    _BIC_SR(LPM0_bits);
    
    }
    void main(void)
    {
    WDTCTL=WDTPW+WDTHOLD;
    P1DIR|=BIT6;
    P1SEL|=BIT6;
    
    while(1)
    {
    timerA_pause();
    _BIS_SR(LPM0_bits+GIE);
    timerA_PWM();
    
    _delay_cycles(5000);
    }
    
    }

    Regards, Ryan

**Attention** This is a public forum