![]() |
DM&P DOS AccTimer Library Reference |
2002/08/02 Version 0.10 |
If you have any problem, mail to soc@dmp.com.tw please.
#include "acctimer.h" #include <time.h> #include <stdio.h> void main() { int i; long t1, t2; clock_t clk; printf("\nDM&P DOS AccTimer Library Version %s\n\n",AccTimer_Version()); if(AccTimer_Init()==0) { printf("Unable to initialize AccTimer library.\n"); return; } printf("Run a loop and get loop time: "); t1 = AccTimer_Read(); for(i = 0; i < 1000; i++); t2 = AccTimer_Read(); printf("Timer = %ld, time = %ldus.\n", t2 - t1, (t2 - t1) * 1000L / 1193L); printf("Detect system ticks (18.2Hz), it will be 1-55ms: "); t1 = AccTimer_Read(); clk = clock(); while(clock() == clk); printf("Time = %ld ms\n", AccTimer_GetTime(t1)); printf("Set time out to 3 seconds and do user's job:\n"); t2 = AccTimer_SetTime(3000); t1 = AccTimer_Read(); while(!AccTimer_IsTimeOut(t2)) { /* do you job here */ printf("\rTime = %4ld ms", AccTimer_GetTime(t1)); } printf(", Time Out!\n"); AccTimer_Uninit(); } |
You will get those messages when you run our demo.exe:
C:\DMP\AccTimer>demo DM&P DOS AccTimer Library Version 0.10 Run a loop and get loop time: Timer = 468, time = 392us. Detect system ticks (18.2Hz), it will be 1-55ms: Time = 53 ms Set time out to 3 seconds and do user's job: Time = 2999 ms, Time Out! C:\DMP\AccTimer> |
Description: | Get library version string. | ||
Arguments: |
|
||
Example: |
/* Show AccTimer version. */ printf("DM&P DOS AccTimer Library Version %s\n",AccTimer_Version()); |
Description: | Initialize AccTimer library. | ||
Arguments: |
|
||
Example: |
if(!AccTimer_Init()) printf("Unable to initialize AccTimer library.\n"); |
Description: | Close AccTimer library. | |
Arguments: |
|
|
Example: |
AccTimer_Uninit(); |
Description: | Read timer ticks. | ||
Arguments: |
|
||
Example: |
printf("Timer ticks = %ld\n",AccTimer_Read()); |
Description: | Set timeout in mini-second. | ||
Arguments: |
|
||
Example: |
printf("Set time out to 3 seconds and do user's job:\n"); t = AccTimer_SetTime(3000); while(!AccTimer_IsTimeOut(t)) { /* do you job here */ } printf("Time Out!\n"); |
Description: | Get time in mini-second from two clock ticks. | ||||
Arguments: |
|
||||
Example: |
t1 = AccTimer_Read(); delay(100); printf("%ld ms passed\n", AccTimer_GetTime(t1)); |
Description: | Check the timer tick from AccTimer_SetTime() is timeout or not. | ||||
Arguments: |
|
||||
Example: |
printf("Set time out to 3 seconds and do user's job:\n"); t = AccTimer_SetTime(3000); while(!AccTimer_IsTimeOut(t)) { /* do you job here */ } printf("Time Out!\n"); |
DMP Electronics Inc. All rights reserved. | Email us: info@dmp.com.tw |