ARM LPC21xx ADC -> Interrupt

Gast #1111069
Lesenswert?
• ▲
▼
Hallo zusammen,

ich habe das Problem, dass mein AD0 beim LPC2138 kein Interrupt auslöst. 
Habe ich irgendetwas vergessen? Die AD-Wandlung
funktioniert soweit. Wenn ich den IRQ weglasse läufts.
1
// AD-CONVERSION
2
VICVectCntl14 = 0x20 | 0x12;    // VICVectCnt# -> Slot14 (priority) 
3
                                // 0x20 -> this vectored IRQ slot is enabled 
4
                                // 0x12 -> bits 0..4 from the VICVectCntrl# define the IRQ you wish to turn on  from 0 to 31 -> AD0 
5
VICVectAddr14 = (unsigned long)isr_ad0;    // AD0 Interrupt -> Vector 14
6
VICIntEnable  = (1 << 18);                 // enables AD0 INT
7

8
AD0CR |= 0x00270600 | (1 << 0); 
9
                   // Bit 21 -> The A/D converter is operational.
10
                               // Bit 19,18,17 -> 011 = 8 clocks / 7 bits 
11
             // Bit 16   -> Burst Mode (!No Start Bit)
12
             // Bit 9,10 -> Clock Divider
13
             // Bit 0    -> Select AD0.0  
14

15
__irq void isr_ad0(void)
16
{
17
  static unsigned int tempadvalue=0;
18
  int i=0;
19

20
  for (i=0; i<MEASURMENTS_PER_VALUE; i++)
21
  { 
22
    tempadvalue = AD0DR0;                         // Read A/D Data Register           
23
    tempadvalue = (tempadvalue >> 6) & 0x03FF;        // Extract AIN0 Value 
24
    measured_values_float[VOLTAGE_1] += tempadvalue;
25
  }
26
}
Grüße

 Ruprecht
Gast #1111278
Lesenswert?
• ▲
▼
Folgendes habe ich wohl noch vergessen:
1
AD0INTEN = (1 << 0);  // ADC channel 0 will generate an interrupt
...geht aber trotzdem nicht :-(

Das Beispiel aus dem lpc-arm-book_srn.pdf bringt bei mir nur noch mehr 
Verwirrung.
1
int main(void) 
2
{ 
3
 VPBDIV = 0x00000002;  //Set the Pclk to 30 MHz 
4
 IODIR1 = 0x00FF0000;      // P1.16..23 defined as Outputs   
5
 ADCR   = 0x00270607;      // Setup A/D: 10-bit AIN0 @ 3MHz  
6
 
7
 VICVectCntl0 = 0x00000032;    // connect A/D to slot 0 
8
 VICVectAddr0 = (unsigned)AD_ISR;   // pass the address of the IRQ into the VIC  
9
            // slot 
10
 VICIntEnable = 0x00040000;  // enable interrupt 
11
 
12
 while(1) 
13
 { 
14
  ;     
15
 } 
16
} 
17
  
18
void AD_ISR (void) 
19
{ 
20
 unsigned val,chan; 
21
 static unsigned result[4]; 
22
 
23
 val = ADCR; 
24
 val = ((val >> 6) & 0x03FF);   // Extract the A/D result  
25
 chan = ((ADCR >>0x18) & 0x07); 
26
 result[chan] = val; 
27
}

Was soll das " val = ADCR; " bewirken? Und wo ist AD0INTEN?

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