I have a problem and cant find the solution.
I use a LPC2138, and need to use interrupts, actually i only need one interrupt for now (but that can change in the future), so i want to implement it throught the VIC., but a can’t make it work. But if i dont use the VIC, if i put the address of the isr directly in the exception vectors in the startup file it works great, a longer explanation:
I’m using a falling edge eint0 interrupt.
if in styrtup.s i have:
ldr pc, irq_addr
.
.
irq_addr: .long nm_isr
The interrupt works perfectly. When the interrupt occurs, the program enters the nm_isr and executes it. If i check the VIC registers with my IDE i see (as expected): EXTINT=0x1, VICVectAddr=address of the nm_isr etc.
Then i try implementing it with the VIC:
startup.s:
ldr pc,[pc,#-0x0ff0]
interrupt setup:
EXTMODE=0x1
EXTPOLAR=0x0
EXTINT=0xf
VICIntSelect=0
VICVectAddr1 = (unsigned long)nm_isr;
VICDefVectAddr = (unsigned long)defint;
VICVectCntl1 = 0x20 | 14;
VICIntEnable=0x4000
The device that causes the external interrupt needs to get an istruction by the I2C bus (which is implemented without interrupts), so in the i2c send function i disable the external interrupt. Then i send the instruction, and as soon as the device gets the instruction it pulls the line low, producing an interrupt. I see, that the mcu acknowledges the interrupt (EXTINT=0x1, VICIntRaw=eint0). Then i re-enable the eint0 interrupt in the VICVectEnable register. At this point i should see that the VICVectAddr loads the address of the interrupt routine, but it doesn’t. It just holds the defint routine address like before the interrupt.
As i said the first implementation (address of routine directly into the interrupt vectors) all works fine, the code is identical, except that the second time i want to do it with the VIC.
The interrupts are enabled at the startup, the mcu works in user mode.
Any ideas?
Thank you.