interrupt on lpc 2138

My interrupt dont work!! why??

int main(void){
configura_gpio();
IOSET1 = 0x00080000;

  PLLCON= 0x00000000;  //No PLL	
  T0TCR = 0x00000002;  //Counter disable
  T0PR = 0x0000000;    //Prescaler Register = 0
  T0MR0 = 6000000;    //velocity
  T0MCR = 0x00000003;  //On MR0: TC reset & interrupt

  /* Setup the VIC for the timer. */
  VICIntSelect &= ~( 0x00000010);   //IRQ - Interrupt
  VICIntEnable |= 0x00000010;     //TIMER Enable //bit4 tmr0
  
  VICVectAddr0 = (unsigned long) vTickISR;
  VICDefVectAddr = (unsigned long) vTickISR;
//  VICVectAddr = 0;
  VICVectCntl0 = 0x00000024;
  
  T0TCR = 0x00000001;  //Counter Enable
 static void vTickISR( void ) __irq
{

 IOCLR1 = 0x00080000;  //LED1 ON
 IOSET1 = 0x00400000;

  T0IR = 0x00000001;  //Clear Interrupt flag
  VICVectAddr = 0x00000000; ;
}

i want to test the interrupt, clear the pin P1.19 and set the pin P1.21

why i´ts doens´t work?

What environment / compiler do you use?

(By your code it looks like gcc)

If your startup asm file (s or s79, typically) features an interruption wrapper, you don’t want to declare your ISR (interruption servicing routine) with __irq or any attribute: the wrapper will perform the return from interruption for you.

You still want to clear the interupt flag and write 0 to VICVectAddr as you did.

Let us know how that works for you.

Hi Big Hairy Troll!!!

i´m using Keil uvision 3.90!!

I take the code for book- The Insider’s Guide To The Philips ARM7-Based Microcontrollers ( Printable) - ARM manual!!

this code work´s in the keil?

thank´s !!!

Hi verd,

First, do you have a tool to look at your LED signal? (oscilloscope / logic analyzer)

Setting your PLL may require you to wait for it to stabilize (although probably not when deactivating it, but then it’s easier to isolate the problems) - try without changing it, it should be set up by your Cstartup.asm (or .s or .s79 or whatever)

You probably want to have a look at the asm file that supports the ARM core exception vectors.

It typically also has your boot up sequence and calls your main().

It should contain something like

LDR PC,Reset_Addr

LDR PC,Undef_Addr

LDR PC,SWI_Addr

LDR PC,PAbt_Addr

LDR PC,DAbt_Addr

NOP

LDR PC,IRQ_Wrapper_addr

LDR PC,FIQ_Addr

(the names of the addresses may be different)

This should be located at address 0, where the ARM core boots.

As you can see by branching at address 0 (upon boot) the core would jump right away to Reset_addr (PC is the program counter: the address of the next instruction to execute).

Then you have the exception vectors for undefined instruction, software interrupt (for your preemptive OS if you have one), (instruction) prefetch abort and data (access) aborts.

After that you have a reserved vector (the one that does nothing: NOP = no operation)

And then you have what you are looking for: the IRQ vector and the FIQ vector.

Typically the IRQ vector should point to some address that is defined in the same assembly file, but that could be declared extern (should be declared above the list in the assembly file).

Wherever it is located, the code there needs to return from interrupt when it is done, which is not the same as simply returning from a function: there is a context switch.

IF the label there is defined in the assembly file you are looking at (Ctrl-f with the name of the label will tell you that), then have a look at the actual code that follows it. If you understand ARM assembly you should figure out whether it pushes the stack, calls the vector provided by the VIC and the pops the stack and returns from interrupt.

If not, chances are it does.

In either case you can try removing the qualification as IRQ.