Jump to content
Sign in to follow this  
samadivk

Energia Multiple Threads

Recommended Posts

Hi

I'm wondering if there's a way to create multiple threads on an msp430g2553 or msp430g2452 using Energia.

My project is to try to get software PWM, so I need to create a loop to turn the pin on and off at the correct times, but in a different thread.

 

Thanks in advance!

Share this post


Link to post
Share on other sites

Msp430 does not have hardware multi-tasking or multi-threading. The closest you can achieve is through the use of a timer interrupt to interrupt the main program and then execute some other code. When the interrupt has completed, control returns back to where the main code was when the interrupt triggered. Inside the interrupt, care needs to be taken to not call code which is not re-entrant, and be certain that it will finish the interrupt routine faster than the timer interrupt.

 

 

Sent from my iPhone using Tapatalk

Share this post


Link to post
Share on other sites

Threading is taking the approach of multi-processing backward. Instead of trying to make your chip into a single sequential machine, observe that the peripherals allow you to do true multi-processing, albeit all except one be very simple tasks.

PWM for example is very well done with the timer. I personally would just apply the timer and use that to set PWM in the ISR (or directly PWM wit the timer if that serves the purpose enough). But Energia is claiming control of the timers, and altering them will affect some of the background stuff that's going on.

So in the case of Energia, you could attach to the millis interrupt (which is provided from a timer) and do SoftPWM in that function.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×