uart inerrupt

Hello all,

i have written code for rx interrupt,but it’s not entering into interrupt function,anyone can tell me where i am doing mistake.

void InitSerial (void)

{

VPBDIV = 0x00;

PLL0CFG = 0x24;

PLL0FEED = 0x55;

PLL0CON = 0x03;

PINSEL0 = 0x00050000; // Enable RxD0 and TxD0

U1LCR = 0x83; // 8 bits,no Parity,1 Stop bit

U1DLL = 97; // 9600 Baud @ 12MHz Clock

U1DLM=0x00;

U1LCR = 0x03; // DLAB = 0

U1FCR=0x07;

U1IIR = 0xC1; // FIFO Enable, No pend. Int

U1FDR = 0x00000010;

VICProtection = 0; // disable protection

//VICIntEnClear = 0xFFFFFFFF; // disable all interruptions

VICIntSelect &= 0xFFFFFF7F; // IRQ -uart1

VICVectAddr1 = (unsigned long)uart1; // Set interrupt vector in 1

VICVectCntl0 = 0x20 | 7; // use it for Serial 0 Int */

VICIntEnable |= 0x00000080;

U1IER |= 0x04;

}

int main (void)

{

//char arr[10];

//static int i;

IODIR1 = 0x00FF0000;

InitSerial();

}

int ReceiveChar (void)

{

while (!(U1LSR & 0x01));

return (U1RBR);

}

int SendChar (int ch)

{

while (!(U1LSR & 0x20));

if(ch == ‘\n’)

return (U1THR = CR);

else

return (U1THR = ch);

}

__irq void uart1(void)

{

unsigned int i;

unsigned char ch;

unsigned char RecivedString[50];

ch = ReceiveChar();

if(ch != CR)

{

RecivedString = ch;
i++;
}
else
{
SendChar(‘\n’);
RecivedString = 0x00;
i = 0;
}
VICVectAddr = 0;
}

I can see several doubtful areas. The first one I would check is:

VICVectAddr1 = …

VICVectCntl0 = …

(Read the VIC chapter in the User Manual).

here’s a section of what I use for LPC21xx.

Common ISR for all (both) UARTs.

An array of structs where each member is a UART’s static variables and ring buffer data/pointers.

Coded for IAR’s IDE/compiler. (free if program < 32KB)

// Initialization
 switch (uartNo)  {
    case 0:      
        // pointer to hardware registers for a UART
        uartBuf->VIC_IEbit = (1<<VIC_UART0); // UART0 Interrupt enable bit
        VICIntEnClear = uartBuf->VIC_IEbit; // disable UARTn interrupt
        uartio = uartBuf->iobase = (struct LPC_UART *)UART0_BASE; // a constant
        PINSEL0 |= (1<<0); // _bit.P0_0 = 1;  //Uart0 TX function select pins 0,1
        PINSEL0 |= (1<<2); // _bit.P0_1 = 1;  //Uart0 RX function select       
        // setup VIC for interrupts from UART
        VICIntSelect &= ~(1<<VIC_UART0); // mark as vectored, not FIQ
        VICVectAddresses[vectorNo] = (unsigned int)&UART0_isr; // Install ISR in VIC addr slot 
        VICVectControls[vectorNo] = 0x20 | VIC_UART0;        // IRQ type, int enabled
        break;
    
  case 1: // same code as case 0 but for the UART1 constants
        uartBuf->VIC_IEbit = (1<<VIC_UART1); // UART0 Interrupt enable bit
        VICIntEnClear = uartBuf->VIC_IEbit; // disable UARTn interrupt
        uartio = uartBuf->iobase = (struct LPC_UART *)UART1_BASE;  // a constant
        PINSEL0 |= (1<<16);  // _bit.P0_8 = 1;     //Uart1 TX function select
        PINSEL0 |= (1<<18);  // _bit.P0_9 = 1;     //Uart1 RX function select
        // setup VIC for interrupts from UART
        VICIntSelect &= ~(1<<VIC_UART1);
        VICVectAddresses[vectorNo] = (unsigned int)&UART1_isr; // Install ISR in VIC addr slot 
        VICVectControls[vectorNo] = 0x20 | VIC_UART1;        // IRQ type, int enabled
        break;

///... omitted code here

/*************************************************************************
Interrupt Function: handle UART0 TX and RX. 
*************************************************************************/
__irq __arm void UART0_isr(void)
{
  UART_isr(0);
}
/*************************************************************************
Interrupt Function: handle UART1 TX and RX
*************************************************************************/
__irq __arm void UART1_isr(void)
{
  UART_isr(1);
}


/*************************************************************************
  *************************************************************************
  *************************************************************************
  *************************************************************************
  Interrupt Function: handle any UARTx TX and RX interrupt
  *************************************************************************/
__arm void UART_isr(unsigned char uartNo)
{