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 reload timer for acceleration in MSP430f5659

Other Parts Discussed in Thread: MSP430F5659

Hello All,

I am programming an msp430f5659 and I need to program a timer to accelerate and then level off at a constant speed for a stepper motor drive.


The first requirement for this project required only to create pulses for a stepper motor at a constant speed with no acceleration, the motor torque was supposed to be adequate.  Easy .   I programmed

P3SEL = 1;                                         // for TA1.0  output bit would have the step pulses coming out

TA1CCTL0 |=  OUTMOD_4;         // for toggle mode

now I could easily load 

 TA1CCR0  with pre-calculated count values representing the constant speed  and life was good. I didn't even need to do an interrupt routine. I did this once upon initializing the processor, and everyone was happy.  

But the party's over.   Seems speed and torque requirements changed so we need acceleration as well which means the pulses coming out of P3.1 are going to change until I hit constant speed at which time the counter will be reloaded with the same count value forever or until someone shuts off the pumps.  

My question is, is there no easy way to do this where I dont have to setup an interrupt routine?  I'm thinking I need to set up an interrupt routine and the interrupt's whole job is to load the counter with the next value of counts.  During accel part of the move at the beginning the counts values with change each time, I actually already calculated what those count values will be in matlab.  When it reaches desired velocity, the count number remains the same.

but I'm worried the very process of calling an interrupt routine will screw up the timing of the pulses coming out to drive the pumps thereby throwing off the speed of the pumping.   I have to do this with two timers for two motors that are supposed to be synchronized .   I precalculated the count values and I'm going to  store them in an array as a #define so it's preprocessed, so the only overhead is retrieve the next count value from memory and load it into the counter - no math calculations required.   

Is there any other way to do this?  I'd so prefer to reload the counter without having an interrupt routine as I do not now, though I'm thinking that's an oxymoronic thing to say.

Thanks for your help 

Dubs

 


 

 

  • There is an easy (and often used) way. Just say: THIS IS URGENT, SEND ME THE CODE IMMEDIATELY!

    But obviously you are doing it the hard way -- try to figure out how to do it yourself.

    With that attitude, nothing will be too hard for you and you do not need the easy way.

    You are correct; all you need to do is to change the pulse interval according to a pre-calculated schedule. Using interrupt to do this can actually simplify the code and reduce the risk of screwing up the timing of the pulses.

    Go ahead and use interrupts. Ask any questions you have.
  • The timer continues to count independently from whatever the CPU does. Assuming you're using Up mode, you need to update CCR0 before the old or new value is reached, but apart from that, the actual time when CCR0 is updated does not matter.

    Or aren't you updating CCR0?

**Attention** This is a public forum