Yahoo Groups archive

Lpc2000

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

Thread

Help with RX interrupt

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

AW: [lpc2000] Help with RX interrupt

2004-05-08 by Sören Rennecke

I think you have forgotten lines like this at the end of Interrupt
routine:


char dummy = 0;
dummy = UARTBT_IIR; 		//clear Interruptflags by reading this
register 
VICVectAddr  = 0x00000000;	//Dummy write, to signal end of
interrupt

AW: [lpc2000] Help with RX interrupt

2004-05-08 by Sören Rennecke

I think you have forgotten lines like this at the end of Interrupt
routine:


char dummy = 0;
dummy = UARTBT_IIR; 		//clear Interruptflags by reading this
register 
VICVectAddr  = 0x00000000;	//Dummy write, to signal end of
interrupt

Re: Help with RX interrupt

2004-05-09 by Frank

Ah, excellent. I was unaware of the need to do the dummy write to
VICVectAddr to signal then end. I will be able to test this tomorrow.
Thank you very much.

-Frank

Re: Help with RX interrupt

2004-05-12 by Frank

It took longer for me to get back to the lab than expected, but lo, 
the code works as expected now. Adding that dummy write to VICVecAddr 
did the trick.

-Frank

--- In lpc2000@yahoogroups.com, "Frank" <frankakrueger@y...> wrote:
> Ah, excellent. I was unaware of the need to do the dummy write to
> VICVectAddr to signal then end. I will be able to test this 
tomorrow.
Show quoted textHide quoted text
> Thank you very much.
> 
> -Frank

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.