Reply by Brian Sidebotham May 22, 20072007-05-22
As always seems to happen, I have it working fine now. The startup file
I am using disables global interrupts!

I crudely added

void EnableInterrupts(void)
{
asm("msr CPSR_c, 0x13 \n");
}

and now the code works fine.

I have been working with the user manual for the LPC2368, and it doesn't
mention anywhere CPSR. So I guess I need to also work with the
ARM7TMDI-S manual too?

Anyway, sorted for now.

Best Regards,

Brian Sidebotham
Brian Sidebotham wrote:
> Hi Guys,
>
> I could do with some pointers as to what I'm doing wrong here. I am
> trying to get the external interrupt EINT0 to work on an LPC2368 on an
> MCB2360 keil development board.
>
> I am using the GNU toolchain, and I'm having difficultly in getting the
> ISR to fire.
>
> I have the following code:
>
> // SELECT P2.10 as EINTO
> PINSEL4 = (1 << 20);
> // DISABLE ETM
> PINSEL10 = 0;
>
> // Set LED pins to outputs + clear them
> FIO2DIR |= 0xFF;
> FIO2CLR = 0xFF;
>
> // *** VIC ***
> // Disable EXT Int 0
> VICIntEnClr = (1<<14);
> // Whilst extint0 is definitely disabled, setup ext0 as edge sensitive
> EXTMODE = 1;
> // Falling Edge sensitive
> EXTPOLAR = 0;
> // Set External Interrupt 0 as a normal IRQ
> VICIntSelect = 0;
> // Set ISR Address as interrupt service routine for interrupt.
> VICVectAddr14 = (int)ExtInt0Isr;
> // Set High Priority Level
> VICVectPriority14 = 1;
> // Enable External Interrupt 0
> VICIntEnable = (1<<14);
> to set the interrupt service routine, and the isr is defined as:
> void ExtInt0Isr(void) __attribute__((interrupt(IRQ)));
> void ExtInt0Isr(void)
> {
> FIO2SET = 2;
> // Required by vectored interrupt controller
> while(1);
> // write anything to register before leaving IRQ
> VICAddress = 0;
> }
>
> But it will never fire. I know the hardware is working on that pin, as I
> can check that the pin voltage level changes appropriately to cause a
> falling edge interrupt.
>
> When I debug with gdb, I get a value of 72 for VICVectAddr14, which is
> correct according to a lst file. I can also see that VICIRQStatus is
> zero to begin with - until I press the int0 button. Then VICIRQStatus
> changes to 0x4000 which is the correct flag for EINT0 which should mean
> that the IRQ is set correctly, enabled, and asserted - so why doesn't it
> get processed?
>
> In the startup script I have the following vector table:
>
> b _start
> ldr pc, _undf
> ldr pc, _swi
> ldr pc, _pabt
> ldr pc, _dabt
> nop
> ldr pc, [pc,#-0x120] /* irq - read vector address */
> ldr pc, _fiq
> This is running from flash, I am using openocd via gdb to program the flash.
>
> Are there any clues from my code above? This is literally all the
> processor is doing, it's what I thought would be a very simple bit of
> code, but I just can't crack it.
>
> Any pointers welcome! If there's any other information that will help,
> please let me know.
>
> Best Regards,
>
> Brian Sidebotham.
>
>
>
> 14:01

An Engineer's Guide to the LPC2100 Series

Reply by Brian Sidebotham May 22, 20072007-05-22
Hi Guys,

I could do with some pointers as to what I'm doing wrong here. I am
trying to get the external interrupt EINT0 to work on an LPC2368 on an
MCB2360 keil development board.

I am using the GNU toolchain, and I'm having difficultly in getting the
ISR to fire.

I have the following code:

// SELECT P2.10 as EINTO
PINSEL4 = (1 << 20);
// DISABLE ETM
PINSEL10 = 0;

// Set LED pins to outputs + clear them
FIO2DIR |= 0xFF;
FIO2CLR = 0xFF;

// *** VIC ***
// Disable EXT Int 0
VICIntEnClr = (1<<14);
// Whilst extint0 is definitely disabled, setup ext0 as edge sensitive
EXTMODE = 1;
// Falling Edge sensitive
EXTPOLAR = 0;
// Set External Interrupt 0 as a normal IRQ
VICIntSelect = 0;
// Set ISR Address as interrupt service routine for interrupt.
VICVectAddr14 = (int)ExtInt0Isr;
// Set High Priority Level
VICVectPriority14 = 1;
// Enable External Interrupt 0
VICIntEnable = (1<<14);
to set the interrupt service routine, and the isr is defined as:
void ExtInt0Isr(void) __attribute__((interrupt(IRQ)));
void ExtInt0Isr(void)
{
FIO2SET = 2;
// Required by vectored interrupt controller
while(1);
// write anything to register before leaving IRQ
VICAddress = 0;
}

But it will never fire. I know the hardware is working on that pin, as I
can check that the pin voltage level changes appropriately to cause a
falling edge interrupt.

When I debug with gdb, I get a value of 72 for VICVectAddr14, which is
correct according to a lst file. I can also see that VICIRQStatus is
zero to begin with - until I press the int0 button. Then VICIRQStatus
changes to 0x4000 which is the correct flag for EINT0 which should mean
that the IRQ is set correctly, enabled, and asserted - so why doesn't it
get processed?

In the startup script I have the following vector table:

b _start
ldr pc, _undf
ldr pc, _swi
ldr pc, _pabt
ldr pc, _dabt
nop
ldr pc, [pc,#-0x120] /* irq - read vector address */
ldr pc, _fiq
This is running from flash, I am using openocd via gdb to program the flash.

Are there any clues from my code above? This is literally all the
processor is doing, it's what I thought would be a very simple bit of
code, but I just can't crack it.

Any pointers welcome! If there's any other information that will help,
please let me know.

Best Regards,

Brian Sidebotham.