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: How to properly disable a PWM signal generated with timer A1?

Part Number: MSP430G2553

Hello, I have the A1 timer set to generate a PWM signal that opens and closes a mosfet that powers the LCD display backlight . What is the correct way to disable the timer to stop the PWM signal (and therefore turn off the LCD display) and set the timer to its default values so you can use it again with other settings? Thanks in advance.

Best regards,
Fran Martin.

  • Hello Fran,

    All of the information regarding controlling TimerA and its operation is found in the User's Guide (slau144j). Section 12.3 thoroughly explains each TimerA register and what bits you can set or clear to deactivate the timer and change its configuration. Hopefully this points you in the right direction!

    Best regards,

    Matt Calvo

  • Thank you! The user manual is the first one I looked at and then I searched information in the forum but I can not stop the timer that generates the PWM signal or at least that I believe because the LCD backligth continues turn on. I do not know what I'm doing wrong. I'll go through it and upload the code.

    Best regards,
    Fran Martín.

  • Fran,

    When I looked at the users guide it looks like there is a bit in the control register that sets the timer in "stop" mode which deactivates the timer. If included a picture below which points it out. It looks like setting the MCx bits to 00 haults the timer. If you think this problem is solved please go ahead and select that my above post resolved your question so that we can close this thread.

    Best regards,

    Matt Calvo

  • Setting TA1CTL:MC=0 (TA1CTL &= ~MC_3;) will freeze the timer. However, it will leave the state of the output (LED backlight) at whatever it happened to be at the moment you froze it.

    To leave the LED the way you want it:
    1) In the appropriate TA1CCTLn: Set OUTMOD=0 and OUT=<led on/off> . (If you do this, you don't really even need to freeze the timer.)
    or
    2) Set the relevant PxSEL.y bit =0 (take the pin away from the timer) and PxOUT.y=<led on/off>. (Don't forget to give the pin back later.)

    Depending on your OUTMOD setting, and how you want the LED left, you might be able to freeze the timer in the CCR0 ISR such that it happens to be left in the state you want it. This is an opportunistic solution, but it might work.

**Attention** This is a public forum