Energia: Code on a Timer with Tiva / Stellaris Launchpads
Do you wish you could smoothly fade LEDs without having to code that into the main loop of your program? Do you wish you could sample sensors or input ports an a regular basis while doing other activities in the main part of your Energia program? Are you looking for simple ways of creating periodic activities without having to worry about timing loops or how long other processing takes in your loop() function? If so, then you want to use a timer interrupts! This post describes how to run time based code in a Tiva/Stellaris Launchpad with 1ms precision. The same code runs on the MSP430 Launchpad with 2ms precision. Your function will be invoked at the interval you register without having to integrate any code in your run loop. The timer is in github along with a simple blinking light demo program. Usage AnyMsTimer calls a function() on regular intervals independent of work you are doing in the the loop() function or the functions it calls. Register your function with