Forum: Compiler & IDEs interrupts bei NXP LPC2468


von kon (Gast)


Lesenswert?

Hallo,

ich versuche mit dem LPC2468 von NXP eine Timer interrupt routine zu 
programmieren komm jedoch in diese nie rein,
obwohl alle nötigen Bits in den Registern gesetzt sind!
1
#include <targets/LPC2468.h>
2
#include <libarm.h>
3
4
void T0_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=0x4004;//PCLK for I2C0 and T0  -> CCLK 
19
  PCLKSEL1=0x4;//PCLK for GPIO selection -> CCLK
20
  
21
  //I2C config
22
  I2C0CONSET=0x20;// I2C0 enable
23
  I2C0SCLH=0xc8;//set to 200
24
  I2C0SCLL=0xc8;//set to 200
25
26
  //GPIO config
27
  IO0DIR &=~(1<<9);//P0.9 is an input
28
  IO0DIR |=1<<10;//P0.10 is an output
29
  IO0CLR |=1<<10;//P0.10 is clear
30
31
  //Power control
32
  PCONP=0x2;//timer T0 enable
33
34
  //T0 config  
35
  T0CTCR=0x0;//increment on rising PCLK edge
36
  T0PR=0xf;//set prescaler
37
  T0IR=0xff;//clears all IR of T0
38
  T0MR0=0xff;//MR0 is set to 0xff
39
  T0MCR=0x3;//enables the MR0R of T0
40
  T0TCR=0x1;//timer T0 and PC enable
41
42
  //VIC config
43
  VICIntSelect=0x0;//IR is an IRQ
44
  VICVectPriority4=0xf;//Priority is set to f of f
45
  VICVectAddr4=(unsigned)T0_IR;
46
  VICIntEnable=0x10;//enables the T0 IR
47
}
48
49
void T0_IR(void)
50
{ 
51
    if((IO0PIN & 0x400) == 0x400 )
52
      IO0CLR |=1<<10;    
53
    else 
54
      IO0SET |=1<<10;
55
}
56
57
int main(void)
58
{
59
  init();
60
61
  while(1)
62
  {
63
    //Tasterfunktion
64
    /*if((IO0PIN & 0x200) == 0x200 )
65
    IO0SET |=1<<10;    
66
    else 
67
    IO0CLR |=1<<10;*/
68
69
    //Timerfunktion
70
    /*if(T0PC <= 0x7f)    
71
      IO0SET |=1<<10;    
72
    else 
73
      IO0CLR |=1<<10;*/  
74
         
75
    int n=0;
76
    n++;
77
  }
78
  return 0;
79
}

von NxP-Checker (Gast)


Lesenswert?

Lass es lieber sein, du hast doch keinen Plan!!!!

von NxP-Checker (Gast)


Lesenswert?

ach halt doch deine fresse!!!

von kon (Gast)


Lesenswert?

wenn du mehr plan hast dann hättest du auch helfen können!

von NxP-Checker (Gast)


Lesenswert?

willst du mir etwa dumm kommen oder was

von kon (Gast)


Lesenswert?

halts maul du blöder wixxer
und bring deine dummen beiträge wo anders ins spiel!

von NxP-Checker (Gast)


Lesenswert?

jetzt hast du mir es aber gegeben, kosta

von NxP-Checker (Gast)


Lesenswert?

Entschuldigung....
ich hoffe jemand anderes kann dir da weiterhelfen
bussi

von Werner B. (Gast)


Lesenswert?

Mal abgesehen davon dass ich nicht weiss wo das problem liegt (oder 
evtl. ist es das problem ?!).

IO0CLR |=1<<10;   ist (ebenso wie IO0SET |=1<<10;) falsch. IO0CLR ist 
ein Read-Only register.

Es gibt für jeden port x ein IOxSET und ein IOxCLR register.

Ein gesetztes bit im CLR register löscht das bit im port und das gleiche 
bit im SET register setzt es.

Read-Modify-Write ist
A) Unnötig.
B) Falsch.

Richtiger
IO0CLR =  1<<10;  // Bit 10 des Port 0 löschen

und

IO0SET = 1<<10;  // Bit 10 des Port 0 setzten.


Viel Erfolg noch

Werner

von kon (Gast)


Lesenswert?

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
}

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.