124 of 323
ZBasic System Library 114 ZX Microcontroller Family GetElapsedMicroTime Type Function returning UnsignedLong Invocation GetElapsedMicroTime(timeBuf) GetElapsedMicroTime(timeBuf, timeBuf2) Parameter Method Type Description timeBuf ByRef array of Byte The earlier time data. timeBuf2 ByRef array of Byte The later time data. Discussion This function is useful for implementing higher precision timing than can be obtained using Register.RTCTick. It calculates the elapsed time between an earlier instant in time (as captured by GetMicroTime()) and a later instant in time. If the second parameter is not provided, the later instant is represented by the RTC time data at the time of the call. The return value has units of the period of the frequency at which the TCNT register of the RTC timer changes, typically 1/230.4KHz or about 4.34uS. The value of Register.RTCTimerFrequency (typically 230.4KHz) may be useful for converting the return value to seconds. The array is expected to contain at least 5 bytes, populated by a previous call to GetMicroTime(). The return value will range from 0 to the equivalent of about 15,000 seconds. A return value of &HFFFFFFFF indicates that an overflow has occurred, i.e. an elapsed time that is too large to represent. Although this function does not take into account the value of the “day” counter of the RTC, it does properly handle an elapsed time that spans one midnight rollover. Example Dim t0(1 to 5) as Byte Call GetMicroTime(t0) <other code> Dim delta as UnsignedLong delta = GetElapsedMicroTime(t0) Compatibility This function is not available on ZX models that are based on the ATmega32 processor (e.g. the ZX-24). Moreover, it is not available in BasicX compatibility mode. See Also GetMicroTime