Frage zu Interrupts auf AT91RM9200

Gast #838067
Lesenswert?
• ▲
▼
Hallo, ich versuche gerade die serielle Debug-Schnittstelle 
interrupt-gesteuert auszulesen. Jedoch habe ich folgendes Problem: die 
ISR wird nicht verlassen, sprich der normale Progrgammcode (jede Sekunde 
wird eine Zahl auf ausgegeben, die per manuellem Interrupt alle 3 Sek. 
inkrementiert wird) wird nicht ausgefuehrt.

Vielleicht kennt sich jemand aus, hier mal der Code

DIe Funktion boot ist die "main"
1
#include <sc/sc_config.h>
2
#define IRQ1 0x1 << AT91C_ID_IRQ1
3
#define SYS 0x1 << AT91C_ID_SYS
4

5

6
// Print dimi converts a HEX-Variable to ASCII
7
unsigned char * Print_dimi(AT91_REG *arg);
8
unsigned int mytestvalue;
9
volatile unsigned int StatusDBGU;
10
int myBool = 0;
11
int myBool2 = 0;
12
void vTimerIncrementTick( void );
13

14

15

16
// Interrupt handler fuer manuellen Interrupt
17
void ext_IRQ1_handler(void)
18
{  
19
  AT91C_BASE_AIC->AIC_IDCR = IRQ1;
20

21
  AT91C_BASE_AIC->AIC_ICCR = IRQ1;
22

23
  // Increment the variable
24
  mytestvalue++;
25
  
26
  // This clears the I bit in the CPSR re-enabling the Interrupts
27
  asm("mrs r7,CPSR");
28

29
  // MRS is status reg to reg
30
  asm("bic r7,r7,#0x80");
31

32
  // BIC instruction = bit clear
33
  asm("msr CPSR,r7");
34

35
  // MSR is reg to status reg
36
  AT91C_BASE_AIC->AIC_IECR = IRQ1; // Interrupt enable command register
37

38
  // Writing anything to IVR will unstack and clear in debug mode
39
  AT91C_BASE_AIC->AIC_IVR = 0x0;
40

41
  // Here acknowledge the end of interrupt
42
  //AT91C_BASE_AIC->AIC_EOICR = 0x0;
43
  AT91F_AIC_AcknowledgeIt(AT91C_BASE_AIC);
44
}
45

46
// DBGU-Interrupt Handler
47
void myInterruptHandler(void)
48
{
49
  unsigned int StatusDBGU;
50
  static char myBuffer;
51

52
  StatusDBGU= AT91C_BASE_DBGU->DBGU_CSR;
53

54
  //Disabe & Clear AIC 
55
  AT91C_BASE_AIC->AIC_IDCR = SYS;
56
  AT91C_BASE_AIC->AIC_ICCR = SYS;
57

58
  StatusDBGU = AT91C_BASE_DBGU->DBGU_CSR;
59

60
  if (StatusDBGU & AT91C_US_RXRDY)
61
  {
62

63
    myBuffer = AT91C_BASE_DBGU->DBGU_RHR;
64
    // Echo
65
    AT91C_BASE_DBGU->DBGU_THR = myBuffer;
66

67
    // Switch LED's
68
    (myBool2) ? (myBool2 = 0) : (myBool2 = 1);
69
    (myBool2) ? (AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, AT91C_PIO_PA18)) : (AT91F_PIO_SetOutput(AT91C_BASE_PIOA, AT91C_PIO_PA18));
70

71
//     AT91C_BASE_DBGU->DBGU_CR = AT91C_US_RSTSTA;
72
  }
73

74
//   AT91C_BASE_DBGU->DBGU_THR = 'x';
75

76
  // This clears the I bit in the CPSR re-enabling the Interrupts
77
   asm("mrs r7,CPSR");
78
  // MRS is status reg to reg
79
   asm("bic r7,r7,#0x80");
80
  // BIC instruction = bit clear
81
   asm("msr CPSR,r7");
82

83
  // Interrupt enable command register
84
  AT91C_BASE_AIC->AIC_IECR = SYS;
85
  // Here acknowledge the end of interrupt
86
  AT91C_BASE_AIC->AIC_EOICR = 0x0;
87

88
}
89

90
//Main
91
void boot(void)
92
{
93
  unsigned int tick;
94
  unsigned int timeout = 0;
95

96

97
  AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, AT91C_PIO_PA18);
98
  
99
  AT91C_BASE_AIC->AIC_IDCR = 0xFFFFFFFF;
100

101
  // Setup Debug Port
102
  sc_setupDebugPort();
103

104
  AT91C_BASE_AIC->AIC_SVR[0x1A]= (unsigned int)&ext_IRQ1_handler;
105
  AT91C_BASE_AIC->AIC_SMR[0x1A]= 0x00000067;
106
  AT91C_BASE_AIC->AIC_IMR = IRQ1;
107
  AT91C_BASE_AIC->AIC_IECR = IRQ1;
108

109
  AT91C_BASE_AIC->AIC_SVR[AT91C_ID_SYS]= (unsigned int)&myInterruptHandler;
110
  AT91C_BASE_AIC->AIC_SMR[AT91C_ID_SYS]= AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE | 0x6;
111
  AT91C_BASE_AIC->AIC_IMR = SYS;
112

113
  //Enable Interrupt
114
  AT91C_BASE_AIC->AIC_IECR = SYS;
115

116
    AT91C_BASE_DBGU->DBGU_IER = AT91C_US_RXRDY;
117
//    AT91C_BASE_DBGU->DBGU_IDR = AT91C_US_TXRDY;
118
//   AT91C_BASE_DBGU->DBGU_IDR = AT91C_US_ENDRX;
119
//    AT91C_BASE_DBGU->DBGU_IDR = AT91C_US_ENDTX;
120

121

122
  // Debug control reg
123
  mytestvalue = 0x19;
124

125
  // We use tick as a timer
126
  tick = *(AT91C_ST_CRTR);
127

128
  while (1)
129
  {
130
    // mytestvalue = AT91C_BASE_DBGU->DBGU_CSR;
131
    // Print the testvalue every second
132
    scDbg(Print_dimi(&mytestvalue));
133
    timeout++;
134

135
    if(timeout>2)
136
    { 
137
      //Generate a test-interrupt every 3 seconds
138
      scDbg("\r\n");
139
      AT91C_BASE_AIC->AIC_ISCR = IRQ1; //set PA26=IRQ1
140
      timeout=0;
141
    }
142

143
    while (tick == *(AT91C_ST_CRTR));
144
    tick = *(AT91C_ST_CRTR);
145
  }
146
}

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren