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.

how to stop and restart the timer without resetting it?

Other Parts Discussed in Thread: MSP430G2533

Hi,

I need to make a program that stops the timer count, read this count, and soon after, turn the count again and it starts where it left off without resetting. I thought I'd just stop using mode 0, then read in a comparison if, for example "if (TAR <10) ..." and soon after turn on again continuously until stopped again and so on.
I wonder also to stop the program I spend cycles of the machine and not stop exatamnete count that I want ...
Hugs!

  • Marco,

    What MSP430 variant are you using?

  • If you clear the main timer control register the timer will stop counting, and the existing count will not be cleared.

    You can resume counting at that count as long as you do not set BIT2 of the control register to clear the counter and you do write something else in the counter.

    The above is true for TimerA, TimerB, as well as TimerD. It has nothing to do with which chip you use.

  • Tyler Witt said:

    Marco,

    What MSP430 variant are you using?

    Tyler,

    The MSP430 variant has nothing to do with the question at hand.

    -- OCY

  • OCY,

    You are correct, the variant doesn't matter. 

    I asked for that information so I could point Marco towards the many code examples that are already created specifically for the variant that he was using.

    Marco,

    As OCY stated, as long as you do not set the TACLR bit in the TACTL register, you should retain the correct count within the TA0R register.

    Additionally, if you are using either the up mode or up/down mode of the timer, you can also set TACCR0 = 0 to stop the timer, then reset TACCR0 to its original value to continue the timer operation.

  • hi OCY and Tyler Witt,

    thanks for the tips!

    I'm using msp430g2533 and would like to make a program that generates 3 ​​PWM signals to control a three-phase motor. I want to change both the Duty Cycle him as the lag.
    I thought about it for use Timer_a microcontroller controlling each cycle count, each stopped the timer count is made​​, and a reading test to see if the count changes state.
    Will use 3 ports output timer. I attached a picture (excuse the drawing badly done) to show a little of what the project would be.
    In the drawing just being varied the duty cycle, which makes the program a little bit, however also want to vary the gap. The signal in black is with duty at 100% and the signal in blue is with variation in duty cycle.

    I doubt if told to stop counting another cycle or 2 of the timer, which will cause errors in the program if I do not prevent me.

    And i need some help for make this program.

    Hugs and thanks again

  • Simply set the timer count moe to stop in order to stop it and back to con/up/up-down mode to continue.
    Unless you set TACLR too, the tiemr will start/continue with wat's current ly in TAR.
    You can even pre-load TAR with a start value of you rchoice, then start the timer.

    Note that a software reset (PUC) won't reset or even stop the timer. A PUC will leave the timers untouched, even their interupts enabled (but blocked, as long as GIE is still clear). Only a POR/BOR will reset the timer registers.

  • Macio,

    Sorry, I do not quite understand what you are trying to do. The waveform in your drawing can be generated by MSP430G2533 under some restrictions.

    (1) The minimum spacing between all the vertical dash lines must be big enough to provide time for the CPU to set them up.

    (2) You must have some way to supply the CPU with the desired position of the next vertical dash line.

    I also do not understand why do you want to stop the Timer from counting. Doing so will stretch the pulse that is currently active. It will also delay all the pulse downstream.

**Attention** This is a public forum