Hallo,
Ich benutzte den C18 compiler und habe folgendes Programm geschreiben.
Es soll auf einen Timerinterrupt und den Externen Interrupt auf RB0 reagieren. Er springt aber nie in die ISR. Ich finden keinen Fehler im Code.
Ich hoffe jemand von euch kann mir helfen. Danke im voraus.
Code:#include <p18f4620.h> #include <usart.h> #include <PortB.h> #pragma config OSC = HS #pragma config DEBUG = OFF #pragma config XINST = OFF #pragma config WDT = OFF #pragma config CP0 = OFF #pragma config LVP = OFF void ISR(); #pragma code high_vector_section=0x8 void high_vector (void) { _asm GOTO ISR _endasm } #pragma code #pragma interrupt ISR void ISR(void) { putrsUSART(">>Interrupt!\n\r"); if(INTCONbits.INT0IF) { putrsUSART(">>Interrupt PortB\n\r"); INTCONbits.INT0IF = 0; //claer the interrupt flag } else if(PIR1bits.TMR2IF) { putrsUSART(">>Interrupt Timer\n\r"); PIR1bits.TMR2IF = 0; } } #pragma code void main() { // Open the USART configured as 8N1, 9600 baud OpenUSART ( USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_LOW, 32); //4.424 --> 57600 //31.55 --> 9600 putrsUSART("\n\asdf\n\r"); TRISBbits.TRISB0 = 1; //RB0 input PIR1 = 0; // Clear the peripheral interrupt flags PIE1bits.TMR2IE = 1; //Enable the timer interrupt INTCONbits.INT0IE = 1; //enable RB0 interrupt INTCONbits.GIEH = 1; // enable global interrupts T2CONbits.TMR2ON = 1; putrsUSART(">>Init Complete!\n\r"); while(1){} }







Zitieren

Lesezeichen