This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

VIC int processing with vectors remapped to memory

Using a LPC2368 & RTX I'm trying to remap exception vectors to RAM in order to run a bootloader and application in separate areas of memory. This is similar to http://www.keil.com/forum/docs/thread10212.asp

Bootloader code is at 0x00000000 - 0x00010000, main code is 0x00010000+, exception vectors are at 0x40000000 I have the RAM exception vectors set to import the handler addresses from a shadow set of vectors in the main startup source - this way the scatterload takes care of updating the copy in RAM when switching from bootloader to main application (or back).

Everything is looking good execpt I can't figure out how to process the VIC interrupt. What I need to do is read the vector address from the VicVectAddr register (0xFFFFFF00 on the LPC2368) and jump to the vector address. The usual technique for this is:

LDR     PC, [PC, #-0x0120]


This works assuming the vector is at 0x18 (PC + 0x08 - 0x120 = 0xFFFFFF00), but I can't figure out what code to use when the PC is over the relative limit (+-0x1000). eg this is invalid:

LDR     PC, [PC, #-0x10120]


What I want to do is something like:

IRQ_Handler     LDR     R0, =0xFFFFFF00
                LDR PC, [R0]


but without clobbering R0.

Yes, it has been a long time since I've had to do any assembly coding.

  • I've altered the routine to preserve r0, and it works, but are open to any suggestions to improve it.

    The RAM exception vectors are set to link to the startup vectors, which are at 0x10000. Again, scatterload takes care of updating RAM when the application is started.

    The startup IRQ vectors gets the VIC address and calls it at below:

    IRQ_Handler
            PUSH {r0} ; dummy push for jump address
            PUSH {r0} ; save r0
            LDR r0, =0xFFFFFF00 ; VicVectorAddr
            LDR r0, [r0] ; r0 = int address to jump to
            STR r0, [sp,#+4] ; place on stack, overwritting dummy r0 push
            POP {r0} ; restore r0
            POP {pc} ; jump to interrupt vector address
    

  • There is no need for the complicated approach that you are suggesting.

    You can simply use the existing instruction:

    LDR PC, [PC, #-0x0120]
    

    This instruction should be placed in RAM at 0x40000018 and REMAP to RAM should be activated which will remap the first 64 bytes from address 0x40000000 to 0 (see NXP manual).

    When an interrupt occurs the core jumps to address 0x00000018 where the remapped instruction from 0x40000018 resides and the PC relative jump is calculated from address 0x00000018.

  • Yes, this works:

    LDR PC, [PC, #-0x0120]
    

    I guess during initial testing I had the RAM vectors jump to a handler at 0x10000.

    Thank you for your help.