-
Notifications
You must be signed in to change notification settings - Fork 36
/
timer.c
48 lines (39 loc) · 800 Bytes
/
timer.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
#include <fx2regs.h>
#include <fx2macros.h>
#include <fx2ints.h>
#include <eputils.h>
#include <delay.h>
#include <autovector.h>
#include <setupdat.h>
#include "fx2bits.h"
#include "fx2extra.h"
#include "fx2timer.h"
void main(void)
{
OEA = 0x00; // port A[0:7] = in
OEB = 0xff; // port B[0:7] = out
OED = 0xff; // port D[0:7] = out
IOB = 0xff;
// SETCPUFREQ(CLK_48M);
// SETIF48MHZ();
SETCPUFREQ(CLK_12M);
USE_USB_INTS();
EA=1;
fx2_setup_timer0(10 * 1000);
while(1) {
PD1 = !PD1;
delay(100);
IOB = IOB + 1;
// IOB = ~IOA;
// IOB = IOA;
}
}
void timer0_isr() __interrupt TF0_ISR {
PD0 = 1;
fx2_timer0_isr();
PD0 = 0;
}
void timer0_callback() {
PD0 = 1;
PD0 = 0;
}