cancel
Showing results for 
Search instead for 
Did you mean: 

return time in microseconds since the board began running the current program

toyboy71
Associate
Posted on October 10, 2012 at 13:12

hi guys! i want to measure the time in microseconds (better would be nano if possible) since my programm started running..

well i would try it via building a delta T (elapsedTime-startTime).

The whole problem is that i dont know how to measure the right way..

i tried it with TIM and counting interuppts..but when i reach a rate of 10us my whole program stucks.. maybe i should use SysTick? but how can i read the current values?

sorry iam very new to the board..used arduino before.. there was a function called micros();

but here its a lot harder;)

i need the us for measuring small capacitys..

iam using the stm32f051r8

#time-duration-counter
2 REPLIES 2
Posted on October 10, 2012 at 18:12

You will definately have issues if you interrupt every 10us, you have several hundred cycles to play with, but at some point you will saturate the processor.

You might want to set a timer to maximal period, and count the updates, using the hw counter for the fractional count. Pick a timer that can clock at the core frequency.

The STM32F0 doesn't have the core cycle counter that would be available in the F1,F2,F4 series parts. That can give you 14 nano-second ticks, and a period of about a mintue at 72 MHz

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist
Posted on October 11, 2012 at 11:06

''i need the us for measuring small capacitys.''

 

Do you mean ''capacitors'', or ''capacitance''?

But what does that have to do with the time since the program started running??

http://www.catb.org/~esr/faqs/smart-questions.html#goal