Main Page Data Structures File List Data Fields Globals Related Pages

# ztimer.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Defines
#define | ZTIMER(function)
| A quick macro for measuring the execution time of function calls.
## Functions
void | ZTimer_Start ()
| Start the ZTimer.
int | ZTimer_Stop ()
| Stop the ZTimer.
void | ZTimer_Report ()
| Show measured time interval.

## Define Documentation

#define ZTIMER | ( | function |  | ) |

| Value:
    ZTimer_Start(),          \
            function,                \
            ZTimer_Stop(),           \
            printf(#function": "),   \
            ZTimer_Report()
A quick macro for measuring the execution time of function calls. This safes some typing, and automatically generates easy-to-read output. example: ZTIMER( LCD_Update() ); output: LCD_Update(): 411us Definition at line 13 of file ztimer.h.

## Function Documentation

void ZTimer_Report | ( |  | ) |

| Show measured time interval. This function prints out the measured time in microseconds. Calling overhead for ZTimer_On and ZTimer_Off is taken into account. (usually 4-5 us on an @chipSC12) Note: this function will call ZTimer_Stop(), if the ZTimer is still running. Definition at line 85 of file ztimer.cpp. References last_t2cnt, ZTimer_Start(), and ZTimer_Stop().

void ZTimer_Start | ( |  | ) |

| Start the ZTimer. This function is to be called just before the piece of code you want to measure. This function uses Timer 2, which is otherwise used by the SC12 Bios. So better don't call any of the BIOS functions, because it could confuse it big time. All interrupts (except NMI) are disabled until a call to ZTimer_Off. Warning: Using the ZTimer will affect the system time of the SC12, and may cause all other sorts of instability. Keep in mind, that the code to measure may not be longer than the watchdog refresh interval. Do not use for production code! Bug: If you notice sporadic system restarts when using the ZTimer, you should try to call the HAL_RefreshWatchdog() function, before using ZTimer_On(). Please send me a mail if this happens/helps. Definition at line 44 of file ztimer.cpp. References isActive, old_t2cmpa, old_t2con, PCB_T2CMPA, PCB_T2CNT, PCB_T2CON, TCON_START, and TCON_STOP. Referenced by gfxTest(), and ZTimer_Report().

int ZTimer_Stop | ( |  | ) |

| Stop the ZTimer. This function has to be called right after the piece of code to measure. Timer 2 is given back to the BIOS, and interrupts are re-enabled. call ZTimer_Report() to show the measured time. Returns: number of microseconds since ZTimer_Start() Definition at line 66 of file ztimer.cpp. References isActive, last_t2cnt, old_t2cmpa, old_t2con, PCB_T2CMPA, PCB_T2CNT, PCB_T2CON, and TCON_START. Referenced by gfxTest(), and ZTimer_Report().