Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

Does SysCtlDelay have counter wrapping issues?

$
0
0

I have found useful posts on how to use SysCtlDelay to implement a usec delay function.  (all my controllers run at > 1MHz).  So I ended up with a function that reads like:

inline void TMR_DelayUS(UINT8 usec) {
    // See user TivaWare user guide or
    // http://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/t/143842.aspx
    // or search for SysCtlDelay
    SysCtlDelay(usec*SysCtlClockGet()/1000000/3);
}

If I were to write this function my self using a timer, I would have to consider timer overflow.  I assume SysCtlDelay is using the sys clock timer, but does the code consider when the timer overflows?
Warning:  I have still not written a GPIO toggle function and put the above code to a test with an oscilliscope. 

P.S.  see below for better code.


Viewing all articles
Browse latest Browse all 262198

Trending Articles



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