![]() It means that ticks1 occured earlier in time than ticks2. Range definition for two’s-complement signed binary integers). Signed value in the range (that’s a typical Values (as long as they not too distant inbetween, see below). (or more specifically, ring) arithmetics to produce correct result even for wrap-around That is why ticks_diff() is needed, it implements modular functions may wrap around, so directly using subtraction on them will Tick_diff(ticks1, ticks2) has the same meaning as ticks1 - ticks2. ![]() The argument order is the same as for subtraction operator, Measure ticks difference between values returned from ticks_ms(), ticks_us(), or ticks_cpu()įunctions. ticks_ms ()) > 0 : do_a_little_of_something () # Find out TICKS_MAX used by this port print ( tick_add ( 0, - 1 )) utime. ticks_ms (), 200 ) while ticks_diff ( deadline, time. ticks_ms (), - 100 )) # Calculate deadline for operation and test for it deadline = tick_add ( time. # Find out what ticks value there was 100ms ago print ( tick_add ( time. (Note: you must use ticks_diff() function to work with ticks_add() is useful for calculating deadlines forĮvents/tasks. However, delta can be an arbitrary integer number To tick_ms(), ticks_us(), ticks_cpu() functions (or from previousĬall to ticks_add()). ticks parameter must be a direct result of call Ticks before or after it, following modular-arithmetic definition of tick values Given a ticks value, this function allows to calculate ticks value delta Offset ticks value by a given number, which can be either positive or negative. Thisįunction is intended for very fine benchmarking or very tight real-time loops.Īvailability: Not every port implements this function. (resolution) of this function is not specified on utime module level, butĭocumentation for a specific port may provide more specific information. high-resolution timer) can be used instead. But it doesn’t have to a CPU clock, some other timing source available in a This is usually CPU clocks, and that’s why the function is named that Similar to ticks_ms and ticks_us, but with the highest possible resolution Just like ticks_ms above, but in microseconds. Invalid results from the latter functions. Performing mathematical operations and then passing their resultsĪs arguments to ticks_diff() or ticks_add() will also lead to Operators (, >=) directly on these value will lead to invalid Note: Performing standard mathematical operations (+, -) or relational The only operations available for themĪre ticks_diff() and ticks_add() functions described below. For the most part, you should treat values Thus, these functions will return a value in range Period value is used for all of ticks_ms(), ticks_us(), ticks_cpu() functions To be a power of two, but otherwise may differ from port to port. The values is TICKS_PERIOD = TICKS_MAX + 1. This value is not explicitly exposed,īut we will refer to it as TICKS_MAX to simplify discussion. Returns an increasing millisecond counter with an arbitrary reference point, sleep_us ( us ) ¶ĭelay for given number of microseconds, should be positive or 0 utime. sleep_ms ( ms ) ¶ĭelay for given number of milliseconds, should be positive or 0. Not accept floating-point argument, for compatibility with them use sleep_ms()Īnd sleep_us() functions. Sleep for a fractional number of seconds. Seconds can be a floating-point number to
0 Comments
Leave a Reply. |