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

Not jumping to ISR

I'm working on developing interrupt driven comms for an lpc2129 and having a problem getting the interrupts working. It all seemed fairly straight forward so I must be missing something. What I have is a short main loop that will echo back any Rx'd bytes on uart1. This works fine until I enable the interrupts for uart1 at which point something goes amuk.

The ISR for uart1 is going to echo the rx'd byte back out the port - simple enough to get started with. When I enable uart1 interrupts and single step via the debugger, I can see the Receive Data Ready interrupt bit get set when I send the uart a character. However, flow continues normally - that is, no jump is made to the ISR. The character I send is then echoed back via the code in the main loop (NOT the ISR).

When I run the code without the debugger I get nothing back from the board via uart1 so I'm assuming I'm getting hung up someplace.

This is the main loop:

while(1)  {
		if( getchar_uart1() )
			putchar_uart1( cTemp );   /* echo any bytes Rx'd */
}

This is the getchar function:
int getchar_uart1( void )  {
	if( U1LSR & 0x01 )   /* if data return it */
		return (U1RBR);
	else
		return 0;
}/* end getchar_uart1 */

The following snippet is the setup code for uart1:
void init_uart1( void )  {
	PINSEL0 |= 0x00550000;   /* set P0.8, P0.9, P0.10 and P0.11 as TxD1, RxD1, RTS1, CTS1 */
	U1LCR = 0x83;   /* set DLAB and word size (8bits), defaults for others yield */
						 /* no parity, one stop bit, and no break */
	U1DLL = 0x61;   /* yields 9600 Baud */
	U1DLM = 0x00;   /* explicit initialization - is also the default */
	U1LCR &= 0x7f;   /* clear DLAB */

/* set up the interrupts */
	U1IER = 0x05;   /* enable RDA and THRE interrupts */
	VICVectAddr1 = (unsigned long) u1_interrupt;   /* set interrupt vector */
	VICVectCntl1 = 0x20 | 7;   /* use VICVectAddr1 for UART1 interrupts */
	VICIntEnable = 0x00000080;   /* enable uart1 interrupts */

}/* end init_uart1() */

and this is the ISR:
void u1_interrupt (void) __attribute__ ((interrupt));   /* generate interrupt */

/*************************************************************************/
/**************************  interrupt for uart1  ************************/
void u1_interrupt (void)  {
	if( U1IIR && U1LSR &= 0x20 ) /* Tx buffer empty? - also clearing U1IIR */
		U1THR = U1RBR;   /* echo the Rx'd byte */
	VICVectAddr = 0;   /* acknowledge interrupt */
}/*end u1_interrupt() */

As I said, when using the debugger and a byte is Rx'd code flow in the getchar_uart1() contiues instead of the ISR. I can see the interrupt triggered in the uart1 peripheral window and the VIC window is also correct (intEnabled for uart1, type IRQ 1).

Any suggestions/solutions appreciated.
-m

Parents
  • True - I removed those calls as soon as I got the interrupts working - which I'm happy to say I finally did (which a little help from tech support)!

    Turned out the problem was in the startup.s code. Had I copied the file from the blinkyIRQ example I would have been all set - but I copied the one from the regular blinky. The vector table in the startup file was not pointing to the correct address. Its worth noting if you weren't already aware that the 7th entry in that table should be:
    LDR pc, [pc, #-0xff0]
    in order to use vectored(and non) IRQ's. There is a brief note about this in the user's manual under the VIC usage notes.

    I appreciate the help though... I'm off to conquer I2C now...

    thanks
    -m

Reply
  • True - I removed those calls as soon as I got the interrupts working - which I'm happy to say I finally did (which a little help from tech support)!

    Turned out the problem was in the startup.s code. Had I copied the file from the blinkyIRQ example I would have been all set - but I copied the one from the regular blinky. The vector table in the startup file was not pointing to the correct address. Its worth noting if you weren't already aware that the 7th entry in that table should be:
    LDR pc, [pc, #-0xff0]
    in order to use vectored(and non) IRQ's. There is a brief note about this in the user's manual under the VIC usage notes.

    I appreciate the help though... I'm off to conquer I2C now...

    thanks
    -m

Children