Yahoo Groups archive

Lpc2000

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

Message

Re: Interrupt Handline

2004-11-08 by Randy Ott

--- In lpc2000@yahoogroups.com, "microbit" <microbit@c...> wrote:
> Hi Robert,
> 
> I went through the same "wondering".
> I noticed that the VICVectAddr gets reset after the vector to weak
> irq_handler. I just copped out and replaced
> 
> >   ldr pc, [pc, #irq_handler_address - . - 8]
> 
> with the classic :
> 
> ldr    pc, [pc , # -0xFF0]
> 
> That sets up VIC to directly vector to your IRQ handler address 
programnmed
> in.
> 
> PS : Don;t forget to update your bootloader checksum in vector 
table when
> you change it !
> 
> -- Kris
> 

Here's the way I do it:

// IRQ exception handler. Calls the interrupt handlers.
__irq __arm void irq_handler(void)
{
	void (*interrupt_function)();
	unsigned int vector;

	vector = VICVectAddr;	 // Get interrupt vector.
	interrupt_function = (void(*)())vector;
	(*interrupt_function)(); // Call vectored interrupt function.
	VICVectAddr = 0;	 // Clear interrupt in VIC.
}

That way you can write the individual ISRs in thumb mode.  The IRQ 
handler must be written in ARM mode because the processor is in that 
mode when an exception occurs.  During linking the weak link to 
irq_handler (or whatever it is called) gets replaced with the C 
function.

Randy Ott

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.