EmbeddedRelated.com
Forums

Compile error: TN06002 LPC2000 EINT dual edge interrupts

Started by liyungsen December 12, 2008
Hi,

I compile the interrupt example code from NXP Technical note below

http://www.nxp.com/acrobat_download/various/TN06002_LPC2000_EINT.pdf
#include "general.h"
#include
#include "startup/config.h"

int main(void);

void EINT0_Isr(void) __irq;
void EINT0_Isr(void) __irq // for external interrupt 0
{
VICIntEnClr = 0x00004000; // Disable EINT0 in the VIC
VPBDIV = 0; // prior to reading EXTPOLAR
if (EXTPOLAR == 0x01)
{
IOSET1 = 0x010000; // P1.16 = 1
VPBDIV = 0;
EXTPOLAR = 0; // next interrupt on falling edge
VPBDIV = 0; // additional step see errata
VPBDIV = 1; // VPB clock = CPU clock
}
else
{
IOCLR1 = 0x010000; // P1.16 = 0
VPBDIV = 0;
EXTPOLAR = 1; // next interrupt on rising edge
VPBDIV = 1; // additional step see errata
// VPB clock = CPU clock
}
EXTINT = 0x01; // Clear the peripheral interrupt flag
VICIntEnable = 0x00004000; // Enable EINT0 in the VIC
VICVectAddr = 0; // reset VIC
}
int main (void)
{
IODIR1 = 0x00010000; // P1.16 defined as GPO
PINSEL1 |= 0x00000001; // P0.16 as EINT0 interrupt pin

VPBDIV = 0;
EXTMODE = 0x01; // EINT0 is (falling) edge-sensitive
VPBDIV = 0x01; // additional step see errata
// VPB clock = CPU clock

VICVectAddr0 = (unsigned int) &EINT0_Isr;
EXTINT = 0x01; // Clear the peripheral interrupt flag
VICVectCntl0 = 0x2E; // Channel0 on Source#14 ... enabled
VICIntEnable = 0x4000; // 14th bit is EINT0

while (1) ;
}

I got the error below,

make[1]: Entering directory `/cygdrive/c/Documents and
Settings/sam/Desktop/EINT
_2129_sam/startup'
rm -f .depend
make[1]: Leaving directory `/cygdrive/c/Documents and
Settings/sam/Desktop/EINT_
2129_sam/startup'
rm -f .depend
arm-elf-gcc -c -mcpu=arm7tdmi -mthumb-interwork -I./startup -DEL -DGCC
-mthumb-i
nterwork -mthumb -DTHUMB_CSTART -DTHUMB_INTERWORK -DLPC2129 -Os
-gdwarf-2 -Wal
l -Wcast-align -Wcast-qual -Wimplicit -Wnested-externs -Wpointer-arith
-Wswitch
-Wreturn-type -Wa,-ahlms=main.lst -o main.o main.c
main.c:39: error: parse error before "__irq"
main.c:39: warning: type defaults to `int' in declaration of `__irq'
main.c:39: warning: data definition has no type or storage class
main.c:50: error: parse error before "__irq"
main.c:51: error: syntax error before '{' token
main.c:53: error: parse error before "volatile"
main.c:57: error: parse error before "volatile"
main.c:58: error: parse error before "volatile"
main.c:59: error: parse error before "volatile"
main.c:60: error: parse error before "volatile"
main.c:65: error: parse error before "volatile"
main.c:66: error: parse error before "volatile"
main.c:67: error: parse error before "volatile"
main.c:70: error: parse error before "volatile"
main.c:71: error: parse error before "volatile"
main.c:72: error: parse error before "volatile"
main.c: In function `main':
main.c:100: error: `EINT0_Isr' undeclared (first use in this function)
main.c:100: error: (Each undeclared identifier is reported only once
main.c:100: error: for each function it appears in.)
make: *** [main.o] Error 1

Thanks for any help

An Engineer's Guide to the LPC2100 Series

Hi,

this code is not for GCC. You need to port it. Google for "attribute
interrupt".

Foltos

liyungsen wrote:
> Hi,
>
> I compile the interrupt example code from NXP Technical note below
>
> http://www.nxp.com/acrobat_download/various/TN06002_LPC2000_EINT.pdf
> #include "general.h"
> #include
> #include "startup/config.h"
>
> int main(void);
>
> void EINT0_Isr(void) __irq;
> void EINT0_Isr(void) __irq // for external interrupt 0
> {
> VICIntEnClr = 0x00004000; // Disable EINT0 in the VIC
> VPBDIV = 0; // prior to reading EXTPOLAR
> if (EXTPOLAR == 0x01)
> {
> IOSET1 = 0x010000; // P1.16 = 1
> VPBDIV = 0;
> EXTPOLAR = 0; // next interrupt on falling edge
> VPBDIV = 0; // additional step see errata
> VPBDIV = 1; // VPB clock = CPU clock
> }
> else
> {
> IOCLR1 = 0x010000; // P1.16 = 0
> VPBDIV = 0;
> EXTPOLAR = 1; // next interrupt on rising edge
> VPBDIV = 1; // additional step see errata
> // VPB clock = CPU clock
> }
> EXTINT = 0x01; // Clear the peripheral interrupt flag
> VICIntEnable = 0x00004000; // Enable EINT0 in the VIC
> VICVectAddr = 0; // reset VIC
> }
> int main (void)
> {
> IODIR1 = 0x00010000; // P1.16 defined as GPO
> PINSEL1 |= 0x00000001; // P0.16 as EINT0 interrupt pin
>
> VPBDIV = 0;
> EXTMODE = 0x01; // EINT0 is (falling) edge-sensitive
> VPBDIV = 0x01; // additional step see errata
> // VPB clock = CPU clock
>
> VICVectAddr0 = (unsigned int) &EINT0_Isr;
> EXTINT = 0x01; // Clear the peripheral interrupt flag
> VICVectCntl0 = 0x2E; // Channel0 on Source#14 ... enabled
> VICIntEnable = 0x4000; // 14th bit is EINT0
>
> while (1) ;
> }
>
> I got the error below,
>
> make[1]: Entering directory `/cygdrive/c/Documents and
> Settings/sam/Desktop/EINT
> _2129_sam/startup'
> rm -f .depend
> make[1]: Leaving directory `/cygdrive/c/Documents and
> Settings/sam/Desktop/EINT_
> 2129_sam/startup'
> rm -f .depend
> arm-elf-gcc -c -mcpu=arm7tdmi -mthumb-interwork -I./startup -DEL -DGCC
> -mthumb-i
> nterwork -mthumb -DTHUMB_CSTART -DTHUMB_INTERWORK -DLPC2129 -Os
> -gdwarf-2 -Wal
> l -Wcast-align -Wcast-qual -Wimplicit -Wnested-externs -Wpointer-arith
> -Wswitch
> -Wreturn-type -Wa,-ahlms=main.lst -o main.o main.c
> main.c:39: error: parse error before "__irq"
> main.c:39: warning: type defaults to `int' in declaration of `__irq'
> main.c:39: warning: data definition has no type or storage class
> main.c:50: error: parse error before "__irq"
> main.c:51: error: syntax error before '{' token
> main.c:53: error: parse error before "volatile"
> main.c:57: error: parse error before "volatile"
> main.c:58: error: parse error before "volatile"
> main.c:59: error: parse error before "volatile"
> main.c:60: error: parse error before "volatile"
> main.c:65: error: parse error before "volatile"
> main.c:66: error: parse error before "volatile"
> main.c:67: error: parse error before "volatile"
> main.c:70: error: parse error before "volatile"
> main.c:71: error: parse error before "volatile"
> main.c:72: error: parse error before "volatile"
> main.c: In function `main':
> main.c:100: error: `EINT0_Isr' undeclared (first use in this function)
> main.c:100: error: (Each undeclared identifier is reported only once
> main.c:100: error: for each function it appears in.)
> make: *** [main.o] Error 1
>
> Thanks for any help
>