C Control Pro application board Mega 128 198258 Benutzerhandbuch

Produktcode
198258
Seite von 200
129
Compiler
© 2005 Conrad Electronic
Parameter 
irqnr
 spezifiziert den Typ des Interrupts (siehe Tabelle)
vect ist der Name der aufzurufenden Interrupt Funktion
Anmerkung
Der Fließkomma Datentyp mag unpassend erscheinen, aber er wird intern als 4 Byte Wert
behandelt. Ein Funktionszeiger muß seit der Mega128 Unterstützung mehr als 16 Bit lang sein.
Tabelle Interrupt Vektoren:
Nr
Interrupt Name
Beschreibung
0
INT_0        
externer Interrupt0
1
INT_1        
externer Interrupt1
2
INT_2        
externer Interrupt2
3
INT_TIM1CAPT 
Timer1 Capture
4
INT_TIM1CMPA 
Timer1 CompareA
5
INT_TIM1CMPB 
Timer1 CompareB
6
INT_TIM1OVF  
Timer1 Overflow
7
INT_TIM0COMP 
Timer0 Compare
8
INT_TIM0OVF  
Timer0 Overflow
9
INT_ANA_COMP 
Analog Comparator
10
INT_ADC      
ADC
11
INT_TIM2COMP 
Timer2 Compare
12
INT_TIM2OVF  
Timer2 Overflow
5.4.9.5
IRQ Beispiel
Beispiel: Verwendung von Interrupt Routinen
// Timer 2 läuft normalerweise im 10ms Takt. In diesem
// Beispiel wird daher die Variable cnt alle 10ms um 1 erhöht
int cnt;
void ISR(void)
{
    int irqcnt;
    cnt=cnt+
1
;
    irqcnt=Irq_GetCount(INT_TIM2COMP);
}
void main(void)
{
    cnt=
0
;
    Irq_SetVect(INT_TIM2COMP,ISR);
    while(true);  
// Endlosschleife
}