vielen Dank erst mal für die Tips!
doch leider funktioniert es auch so nicht!
der interrupt wird ausgelöst und es wird auch die interrupt service
routine aufgerufen.
aber aus irgend einen grund wiederholt er mehrmals die interrupt
routine,
obwohl der T1IR wieder gelöscht wurde.
bis er dann irgendwann wieder zu main zurückspringt.
1 | #include <targets/LPC2468.h>
|
2 | #include <libarm.h>
|
3 |
|
4 | void T1_IR(void) __attribute__ ((interrupt ("IRQ")));
|
5 |
|
6 | void init(void)
|
7 | {
|
8 | /*
|
9 | //CLock source selection
|
10 | CLKSRCSEL=0x1;//Selects the main oscillator as the PLL clock source
|
11 |
|
12 | //PLL config
|
13 | PLLCON=0x3;//PLL enable and connect
|
14 | PLLCFG=0x13;//select N=1 and M=20
|
15 | PLLFEED=0xAA;//PLL feed
|
16 | PLLFEED=0x55;//PLL feed*/
|
17 |
|
18 | PCLKSEL0=0x4010;//PCLK for I2C0 and T1 -> CCLK
|
19 | PCLKSEL1=0x4;//PCLK for GPIO selection -> CCLK
|
20 |
|
21 | //Power control
|
22 | PCONP=0x4;//timer T1 enable
|
23 |
|
24 | //GPIO config
|
25 | IO0DIR &=~(1<<9);//P0.9 is an input
|
26 | IO0DIR |=1<<10;//P0.10 is an output
|
27 | IO0CLR |=1<<10;//P0.10 is clear
|
28 |
|
29 | //I2C config
|
30 | I2C0CONSET=0x20;// I2C0 enable
|
31 | I2C0SCLH=0xc8;//set to 200
|
32 | I2C0SCLL=0xc8;//set to 200
|
33 |
|
34 | //T1 config
|
35 | T1CTCR=0x0;//increment on rising PCLK edge
|
36 | T1PR=0xfff;//set prescaler
|
37 | T1IR=0xff;//clears all IR of T1
|
38 | T1MR0=0xffff;//MR0 is set to 0xffff
|
39 | T1MCR=0x3;//enables the MR0R of T1
|
40 | T1TCR=0x1;//timer T1 and PC enable
|
41 |
|
42 | //VIC config
|
43 | VICIntSelect=0x0;//IR is an IRQ
|
44 | VICVectPriority5=0x7;//Priority is set to 7 of f
|
45 | VICVectAddr5=(unsigned)T1_IR;
|
46 | VICIntEnable=0x20;//enables the T1 IR
|
47 |
|
48 | libarm_set_irq(1);
|
49 |
|
50 | }
|
51 |
|
52 | void T1_IR(void)
|
53 | {
|
54 | T1IR=0x1;
|
55 |
|
56 | if((IO0PIN & 0x400) == 0x400 )
|
57 | IO0CLR = 1<<10;
|
58 | else
|
59 | IO0SET = 1<<10;
|
60 |
|
61 | VICAddress=0;
|
62 | }
|
63 |
|
64 | int m=0;
|
65 |
|
66 | int main(void)
|
67 | {
|
68 |
|
69 | init();
|
70 |
|
71 | while(1)
|
72 | {
|
73 | //Tasterfunktion
|
74 | /*if((IO0PIN & 0x200) == 0x200 )
|
75 | IO0SET = 1<<10;
|
76 | else
|
77 | IO0CLR = 1<<10;*/
|
78 |
|
79 | //Timerfunktion
|
80 | /*if(T0PC <= 0x7f)
|
81 | IO0SET = 1<<10;
|
82 | else
|
83 | IO0CLR = 1<<10;*/
|
84 |
|
85 |
|
86 | m++;
|
87 |
|
88 | }
|
89 | return 0;
|
90 | }
|