-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock_test.c
51 lines (47 loc) · 1014 Bytes
/
clock_test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include <stdint.h>
#define TIME_END 0xFFFFFFF
#define TIME_STEP 333
#define RATE 200
int main(void) {
uint32_t now = 0;
uint32_t runTime = now;
printf("Beginn\n");
while (now < TIME_END) {
uint8_t canRun = (int32_t) (now - runTime) >= 0;
if (canRun) {
static uint32_t cum;
static uint32_t last;
static uint32_t s;
if (now - last >= 1000) {
s++;
last = now;
}
/*cum += now - last;
if (cum >= 1000) {
cum -= 1000;
s++;
// printf("now = %u ", now);
// printf("s = %u ", s);
// printf("\n");
}
last = now;*/
// printf("now-runTime = %d ", (int16_t) (now - runTime));
// printf("now = %u ", now);
// printf("runTime = %u ", runTime);
// printf("s = %u ", s);
// printf("cum = %u ", cum);
// printf("\n");
if (s != now/1000) {
printf("Fehler ");
printf("now = %u ", now);
printf("s = %u ", s);
printf("\n");
break;
}
runTime = runTime + RATE;
}
now += TIME_STEP;
}
printf("Ende\n");
}