This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC2100 UART ISR

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.

Parents
  • hi,

    sorry for not following the posting rules. i am desperate about finishing this code. i also have gone through the manuals and data sheet for LPC2129 and develop the code only from the examples available on KEIL example codes.

    here "code is getting interrupted, but the control is not switched to the corresponding ISR" means
    1.the U1RBR is loaded with the value sent over serial port.
    2.RDR bit is set in U1LSR
    3.Bit 7 is set on the VICIRQStaus register
    4.VICVectAddr is changed from 0x00000128 to 0x0000013C.(VICVectAddr0=0x0000013C)(in the VIC Box)

    but the code written in the UART1 ISR is not invoked.
    in the ISR i tried to display the hex equivalent of the received character in the GPIO1 (bit16-bit23).

    once the first character is received, the code becomes still.it cannot accept further characters.

    since VICVectaddr is changed on receiving a character, i thought the DefVICVectAddr may not be significant.

Reply
  • hi,

    sorry for not following the posting rules. i am desperate about finishing this code. i also have gone through the manuals and data sheet for LPC2129 and develop the code only from the examples available on KEIL example codes.

    here "code is getting interrupted, but the control is not switched to the corresponding ISR" means
    1.the U1RBR is loaded with the value sent over serial port.
    2.RDR bit is set in U1LSR
    3.Bit 7 is set on the VICIRQStaus register
    4.VICVectAddr is changed from 0x00000128 to 0x0000013C.(VICVectAddr0=0x0000013C)(in the VIC Box)

    but the code written in the UART1 ISR is not invoked.
    in the ISR i tried to display the hex equivalent of the received character in the GPIO1 (bit16-bit23).

    once the first character is received, the code becomes still.it cannot accept further characters.

    since VICVectaddr is changed on receiving a character, i thought the DefVICVectAddr may not be significant.

Children
  • Shouldn't you enable the interrupts _after_ you have installed the interrupt vector? What if you get one spurious interrupt before the vectors have been configured? Who will then acknowledge the interrupt?

  • 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.