Interrupt

I’m trying to program an interrupt for the LPC-2148

It seems there’s not that much information about interrupts using the

YAGARTO GCC-compiler…

This is what I already have/tried/found on other sites (only interrupt

code):

/* *********************************************************

Function declarations

********************************************************* */

#include “lpc214x.h” //header file

#define PLOCK 0x400

void Initialize(void);

void feed(void);

void attribute ((interrupt(“IRQ”))) IRQ_Routine(void) ;

void attribute ((interrupt(“FIQ”))) FIQ_Routine(void) ;

void attribute ((interrupt(“SWI”))) SWI_Routine (void) ;

void attribute ((interrupt(“UNDEF”)))UNDEF_Routine (void);

void Initialize(void) {

PLLCFG=0x24;

feed();

PLLCON=0x1;

feed();

while(!(PLLSTAT & PLOCK)) ;

PLLCON=0x3;

feed();

MAMCR=0x2;

MAMTIM=0x4;

VPBDIV=0x02;

}

void feed(void)

{ PLLFEED=0xAA;

PLLFEED=0x55;

}

void delay_ms(long ms)

{

unsigned long i,j;

for(i=0;i<ms;i++) // Time delay function

for(j=0;j<6653;j++);

}

/**********************************************************

MAIN

**********************************************************/

void main(void)

{ Initialize();

IODIR0 |= (1<<21);

IOSET0 |= (1<<21);

EXTMODE |= 0x4;

PINSEL0=0xC000; //15:14

VICVectAddr0=(unsigned)IRQ_Routine;

VICVectCntl0= 0x20 | 16;

VICIntEnable |= 1<<16;

while(1);

}

void attribute ((interrupt(“IRQ”))) IRQ_Routine(void)

{

IOCLR0 |= (1<<21);

EXTINT|=0x4; //Clear EINT2 interrupt flag

VICVectAddr=0;

}

void FIQ_Routine(void)

{

while(1);

}

void SWI_Routine (void)

{

while(1);

}

void UNDEF_Routine (void) {

while (1) ;

}

It compiles without any errors/warnings, but it doesn’t work. The µC

never jumps to the interrupt-routine.

Can’t find more information about this :-(. Anyone knows

what I’m doing wrong?

Your post does not mention if you configured your assembly language startup file to use interrupts, or not. Out of reset, ARM’s interrupts are disabled and must be specifically enabled in order to work.

–Dave

Thank you.

Can anyone explain to me how I can enable Interrupts in my Startup-Code?

I searched in the forum but couldn’t find anything, so I’ll ask in this topic that seems appropriate:

Does GNU ARM compiler have functions to enable/disable irq and fiq?

Or I need to write them in assembly?

I am also interested in functions that return for example 1 if irq are enabled and return 0 if disabled, is something like this available in GNU ARM?

The gnu compiler itself doesn’t have a built in function, but many of the

“packages” aka, winarm, do.

Personally, I just write it in assembly.

Its about 3 lines IIRC, 2 to query.

Cheers,

–David Carne