Jump to content

Recommended Posts

Has anyone ported MsTimer2 to the MSP430? The MSTimer2 Arduino library provides a simple interrupt driven mechanism for getting timed function invocation. I've used it to control fader and polling intervals without having to sit in delay() loops. It looks like TimerSerial and Servo make use of intterupt vectors. TimerSerial uses both Timer0_A0 and Timer0_A1 while servo uses Timer0_A0. It seems like an MSTimer2 port could use Timer0_A1 so that both servos and the timer could be used at the same time. I have a couple questions.



Does TimerSerial or Servo usage mess with the PWM pins tied to that same timer? And by extension would MsTimer2 mess with pwm pins?


If PWM is still available, does that 500Hz PWM rate imply an interrupt vector calling rate of 1/2ms?


T0A2 (T A0 CCR2) isn't used on 20 pin devices. Can this timer/interrupt/CCR be used to generate interrupts while leaving the PWM timers/CCR alone? This question may show some ignorance around how the CCR/Timers inter-operate.


The TI docs refer to the vectors as Timer0_A3 and Timer1_A3. Should there a comment in the docs that mention those are the same as energia defined Timer0_A0 and Timer1_A1?


Note: Using the watchdog for Delay() and Millis() is a slick idea.

Link to post
Share on other sites

I've ported a version of MsTimer2 to the Energia / MSP430 environment. Its called TwoMsTimer and it provides a way to get a method called on regular intervals, as fast as once very two msec. You just create a TwoMsTimer object passing in the (void) method that you want called and TwoMsTimer will take care of the rest. The timer relies on Timer 1 in a way that is compatible with PWM letting you use the Timer 1 PWM pins and get timed function invocation. It is named TwoMsTimer because the PWM CCR0 interrupt rate is about 500Hz giving us 2 msec resolution.


You can find the sample code and a demo showing how it works on http://joe.blog.freemansoft.com/2012/09/msp430-fading-and-other-long-running.html


The code is really simple with no "if define" behavior for different processors. I've only tested it on the Launchpad with the 2553 processor.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...