Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Help with RX interrupt

2004-05-08 by Frank

Hello, I am attempting to write an interrupt handler for UART0 of an 
LPC2106 under GCC 3.3. The handler is invoked for the first byte sent 
to the UART but is not invoked for subsequent bytes. I initialize the 
port with:

int init_uart0(int baud)
{
	const unsigned long divisor = vpb_freq / (baud * 16);

	// set p0.0 to txd0 and p0.1 to rxd0
	PINSEL0 |= (0x01 << 0) | (0x01 << 2);

	// set for 8 bits, no parity, 1 stop, access latch divisor
	UART0_LCR = 0x03 | 0x80;

	// set the baud
	UART0_DLL = divisor & 0xFF;
	UART0_DLM = (divisor >> 8) & 0xFF;

	// kill access to latch divisor
	UART0_LCR &= ~0x80;

	// enable rts
	UART0_MCR = 0x00;

    // enable the FIFO
    UART0_FCR = 1;

	// enable the interrupts
	UART0_IER = (1<<0); // enable RBR int
    VICIntSelect = 0;
    VICVectAddr0 = (unsigned long)uart0_int_handler;
    VICVectCntl0 = 0x00000026;
    VICIntEnable = (1 << 6);

	return 0;
}

The interrupt handler is:

__attribute__ ((interrupt("IRQ")))
void uart0_int_handler()
{
    byte iir;
    byte b;

    if (IOSET & (1<<19))
    {
        IOCLR = (1 << 19);
    }
    else
    {
        IOSET = (1 << 19);
    }

    iir = UART0_IIR;

    switch (iir & 0x0F)
    {
    case 6: //0b0110:
        // Rx Line Status Error
        b = UART0_LSR;
        break;

    case 4: //0b0100:
        // Rx Data Available
        b = UART0_RBR;
        uart0_buf.push_back(b);
        break;

    case 12: //0b1100:
        // Character Timeout Indication
        b = UART0_RBR;
        break;
    }
}

(I am using P0.19 to detect when the handler is called -- I am 
without JTAG at the time).

In my vector table, I have:

LDR     PC, [PC, #-0x0FF0]     /* Vector from VicVectAddr */

for the IRQ slot.

Does anyone have any idea why the handler is called only for the 
first byte? Thank you very much.

-Frank A. Krueger

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.