hi,
i am new to ARM7, i tried a code to receive characters through serial port and process the character in the serial port ISR. the code is getting interrupted, but the control is not switched to the corresponding ISR.please help me through this.
here is my code
#include <stdio.h> #include <lpc21xx.h>
void U1ISR(void)__irq; //Declare UART1 IRQ ISR
int data,clear,dummy;
void DefISR (void) __irq { ; }
int main (void) {
PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */ IO1DIR = 0x00FF0000; /* P1.16..23 defined as Outputs */ IO1CLR= 0x00FF0000; /* turn off LEDs */
U1IER = 0; /* Disable UART1 Interrupts */ U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ U1DLL = 97; /* 9600 Baud Rate @ 12MHz VPB Clock */ U1LCR = 0x03; /* DLAB = 0 */ U1FCR = 0x07; /*Enables and Resets FIFO, 1 byte */ dummy = U1IIR; /* Read IrqID - Required to Get Interrupts Started */ U1IER = 0x01; /*Enable the RDA interrupt*/
VICVectAddr0 = (unsigned long)U1ISR; //Set UART1 ISR Vector Address VICVectCntl0 = 0x20 | 7; //Enable Slot, Set Channel 7 VICIntEnable = 0x80; //Enable Int UART1 VICDefVectAddr = (unsigned long) DefISR; // un-assigned VIC interrupts
while (1) {
} //END OF WHILE LOOP } // END OF MAIN LOOP
void U1ISR(void)__irq //UART1 ISR { clear=U1LSR; //UART Line Status Register data = U1RBR; // UART Receiver Buffer Register data<<=16; IO1CLR=0x00FF0000; IO1SET=data; /*Displaying the DATA on GPIO1*/ VICVectAddr = 0; /* Acknowledge Interrupt*/ return; }
thank you.
i placed a break point in the ISR routine and also changed the Interrupt enabling line after the interrupt configuration, but still the problem exists.
i also check the Program Counter data in the Watch window,it never goes to ISR address,that's why i felt ISR is not invoked.
i checked the same code with Polling method it is working fine.
the code is
#include <stdio.h> /* prototype declarations for I/O functions */ #include <lpc21xx.h> /* LPC21xx definitions */ void U1ISR(void)__irq; //Declare UART1 IRQ ISR int data,clear,dummy; char data1; void DefISR (void) __irq { VICVectAddr = 0; /* Acknowledge Interrupt*/ return; } int main (void) { VICVectAddr0 = (unsigned long)U1ISR; //Set UART1 ISR Vector Address VICVectCntl0 = 0x20 | 7; //Enable Slot, Set Channel 7 VICIntEnable = 0x80; //Enable Int UART1 VICDefVectAddr = (unsigned long) DefISR; // un-assigned VIC interrupts PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */ IO1DIR = 0x00FF0000; /* P1.16..23 defined as Outputs */ IO1CLR= 0x00FF0000; /* turn off LEDs */ U1IER = 0; /* Disable UART1 Interrupts */ U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ U1DLL = 97; /* 9600 Baud Rate @ 12MHz VPB Clock */ U1LCR = 0x03; /* DLAB = 0 */ U1FCR = 0x07; /*Enables and Resets FIFO, 1 byte */ dummy = U1IIR; /* Read IrqID - Required to Get Interrupts Started */ U1IER = 0x01; /*Enable the RDA interrupt*/ while (1) { if(U1LSR & 0x01) { clear=U1LSR; data1 = U1RBR; // UART Receiver Buffer Register while (!(U1LSR & 0x20)); U1THR = data1; } } //END OF WHILE LOOP } // END OF MAIN LOOP void U1ISR(void)__irq //UART1 ISR { clear=U1LSR; //UART Line Status Register data = U1RBR; //UART Receiver Buffer Register data<<=16; IO1CLR=0x00FF0000; IO1SET=data; /*Displaying the DATA on GPIO1*/ VICVectAddr = 0; /* Acknowledge Interrupt */ return; }
here the main's loop code echo the character on UART, this works fine. but the ISR is not working.