NetBurner 3.5.6
PDF Version
High Resolution Delay Timer

High-precision microsecond delay functionality. More...

Classes

class  DelayObject
 High-resolution microsecond delay timer class. More...
 

Detailed Description

High-precision microsecond delay functionality.

#include< HiResDelay.h>

The High Resolution Delay Timer provides microsecond-precision timing by utilizing hardware system timers. This is ideal for applications requiring precise timing control such as:

Usage Overview

When a DelayObject is created, it automatically allocates an available hardware system timer from the processor's timer pool. The timer remains allocated for the lifetime of the object and is automatically freed when the object goes out of scope or is destroyed.

Timing Precision

Example Usage

#include <HiResDelay.h>
void performPreciseTiming() {
// Create delay object - allocates hardware timer
static DelayObject myHiResDelay;
// Verify timer was successfully allocated
if (!myHiResDelay.valid()) {
iprintf("Error: No free timers available\n");
return;
}
// Perform precise delays
myHiResDelay.DelayUsec(100); // Delay 100 microseconds
myHiResDelay.DelayUsec(200); // Delay 200 microseconds
myHiResDelay.DelayUsec(1000); // Delay 1 millisecond
}
// Timer is automatically freed when object goes out of scope
High-resolution microsecond delay timer class.
Definition HiResDelay.h:164
bool valid()
Verify the delay object is valid and ready to use.
Definition HiResDelay.h:318
void DelayUsec(uint32_t usec)
Perform a blocking delay with microsecond precision.

Important Notes

Comparison with Other Timing Methods

Method Resolution Blocking Use Case
OSTimeDly() 20ms (1 tick) Yes General delays
DelayObject Microseconds Yes Precise hardware timing
IntervalTimer Microseconds No Periodic callbacks
Stopwatch Microseconds No Time measurement
See also
Interval Timer Interval Timer for non-blocking periodic operations
Stopwatch Timer Stopwatch for time measurement
OSTimeDly() Standard RTOS delay function