Add TINI target
[fw/sdcc] / support / tests / dhrystone / clock.c
1 #include <ds80c390.h>
2 #include <stdio.h>
3
4 #include "clock.h"
5
6 volatile unsigned long milliSeconds=0;
7
8 #define RELOAD_VALUE 18432000/2/CLOCKS_PER_SEC 
9
10 void Timer2Handler (void) interrupt 5 using 1 {
11   TF2=0; // reset overflow flag
12   milliSeconds++;
13   // that's all for now :)
14 }
15
16 // we can't just use milliSeconds
17 unsigned long clock(void) {
18   unsigned long ms;
19   ET2=0;
20   ms=milliSeconds;
21   ET2=1;
22   return ms;
23 }
24
25 void startTimer (void) 
26 {
27   printf ("\n\rStarting timer 2 test.\n\r");
28
29   // initialise timer
30   ET2=0; // disable timer interrupts initially
31   T2CON=0; // stop, timer mode, autoreload
32   T2MOD&=0xf4;
33   
34   TL2=RTL2=(-RELOAD_VALUE)&0xff;
35   TH2=RTH2=(-RELOAD_VALUE)>>8;
36   TR2=1; // run
37
38   ET2=1; // enable timer interrupts
39 }
40
41