interrupt in LPC2148

Dear all,

i have pasted the uart interrupt program…it doesn’t give any output on hyper terminal,during step by step execution i didn’t enter into the interrupt service loop…

Any one can guide me where I’m doing mistake…

#include<LPC214x.h>

#include<stdio.h>

void UART0_IN(void)__irq;

void serial(void);

int main()

{

IODIR1=0x00FF0000; //port direction control register

serial();

PINSEL0=0x00000005; //pin function select register

VICIntSelect=0x00000040;//enable VIC channel as FIQ

VICVectAddr0=(unsigned int )UART0_IN;

VICVectCntl12=0x20 | 6; //enable uart0 interrupt slot6

VICIntEnable=0x00000040;//enable uart0 interrupt in vic

}

void UART0_IN(void)__irq

{

while(!(U0LSR&0x01));

U1THR=‘J’;

VICVectAddr=0;

}

I’d recommend trying to get it to work as a normal IRQ instead of an FIQ first. If you are using an FIQ I believe you have to install the FIQ handler into the system’s FIQ interrupt address.

Also the VICVectAddr0 / VICVectCtrl2 combination doesn’t look right to me. Check the VIC chapter in the LPC2148 User Manual (UM10139)

There are lots of examples of code on handling the LPC21xx UART. Here’s some I wrote…

// I/O syntax is from IAR's .h files
#define vectorNo xxx // index
        VICIntEnClear = (1<<VIC_UART0); // disable UARTn interrupt
        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
        // now setup the baud rate, etc
__irq __arm void UART0_isr(void)
{
  UART_isr(0);
}  Interrupt Function: handle any UARTx TX and RX interrupt
  *************************************************************************/
__arm void UART_isr(unsigned char uartNo)
{  
  struct UART_UARTBUF *uartBuf; // pointer to UART buffer managemement
  struct LPC_UART *uartio; // pointer to hardware registers
  unsigned char ch, IIRwas, rx;

  // pointer to buffer management for the interrupting UART
  uartBuf = &uartBufs[uartNo];
  // pointer to hardware registers for the interrupting UART
  uartio = uartBuf->iobase;
  
  // Process all pending TX or RX interrupts...

  while ( ( (IIRwas = uartio->IIR) & 1) == 0) { // interrupt request is pending if 0 
    switch( (IIRwas >> 1) & 7)  { // Interrupt ID. Table 89 in LPC manual    
      
// etc, etc