Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 62309

Forum Post: RE: How to Implement a software timer on msp430 ?

$
0
0
You cannot implement software timer without help from hardware timer. So you shall get familiar with hardware timer first, build code that calls timer interrupt service routine (ISR) 100 or 1000 times per second. Then next step would be implementing software timer(s) code in the hardware timer ISR. Example of supersimple implementation of two software period timers: volatile counter1 = 0; volatile counter2 = 0; hw_timer_isr() { // running 100 times/sec if (++counter1 >= 10) { do_something_each_100msec(); counter1 = 0; } if (++counter2 >= 100) { do_something_each_1sec(); counter2 = 0; } }

Viewing all articles
Browse latest Browse all 62309

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>