EmbeddedRelated.com
Forums

Switch interrupt vector from flash to RAM

Started by kd7vn April 28, 2008
Is there any advantage to switching the interrupt vectors from flash
memory to RAM (lpc 2378)? Is it needed if I plan to run my program
out of RAM memory?

This question arose when I came across the following in the user manual.

"Re-mapped memory areas, including the Boot ROM and interrupt vectors,
continue to appear in their original locations, in addition to the
remapped addresses"

-Markus

An Engineer's Guide to the LPC2100 Series

kd7vn schrieb:
> Is there any advantage to switching the interrupt vectors from flash
> memory to RAM (lpc 2378)? Is it needed if I plan to run my program
> out of RAM memory?

If your code runs out of ram, it makes sense to have the vectors also in
ram.
If you run out of flash and the vectors during runtime are the same as
during boot, why waste 0x40 bytes ?

--
42Bastian

Note: SPAM-only account, direct mail to bs42@...

> Is there any advantage to switching the interrupt vectors from flash
> memory to RAM (lpc 2378)?

If you want to be able to change the (real) interrupt vectors at run
time it is a must.

But of course you could always jump over a trampoline in RAM to achieve
the same effect, at the cost of a few cycles.

> Is it needed if I plan to run my program
> out of RAM memory?

I don't see why.

--

Wouter van Ooijen

-- -------
Van Ooijen Technische Informatica: www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: www.voti.nl/hvu
--- In l..., Wouter van Ooijen wrote:
>
> > Is there any advantage to switching the interrupt vectors from flash
> > memory to RAM (lpc 2378)?
>
> If you want to be able to change the (real) interrupt vectors at run
> time it is a must.
>
> But of course you could always jump over a trampoline in RAM to achieve
> the same effect, at the cost of a few cycles.
>
> > Is it needed if I plan to run my program
> > out of RAM memory?
>
> I don't see why.
>
> --
>
> Wouter van Ooijen
thank you for the response.
The user manual by way of an example points out.
For example, whenever a Software Interrupt request is generated, ARM
core will always
fetch 32 bit data "residing" on 0x0000 0008 see Table 210 "ARM
exception vector
locations" on page 21. This means that when MEMMAP[1:0] = 10 (User RAM
Mode),
read/fetch from 0x0000 0008 will provide data stored in 0x4000 0008."

Based on this I assume that the chip will still check the flash memory
address and not the RAM address after a remap. If my assumption is
correct I have no idea what I gain from remapping.

I.e. if an IRQ request comes, the processor will read/fetch from
0x0000 00018, and that address will have the same information that is
in 0x4000 0018. If this is true I'm not sure what I'm getting by
remapping.

I may even be loosing something as the LPC2378 uses the PrimeCell 192
Vector Interrupt Controller. The PrimeCell technical manual points
out that that if an address to be read is more than 4K away it takes
an extra memory cycle to read (3-2 ARM PrimeCell Vectored Interrupt
Controller (PL192) Technical Reference Manual). If all my ISR's are
in RAM they will all be over 4K from flash, if in fact the arm always
reads out of flash. Now its true burning one cycle is not a big deal,
but I'm trying to fully understand this, and some more insight would
be helpful.

-Markus
> For example, whenever a Software Interrupt request is generated, ARM
> core will always
> fetch 32 bit data "residing" on 0x0000 0008 see Table 210 "ARM
> exception vector
> locations" on page 21. This means that when MEMMAP[1:0] = 10 (User RAM
> Mode),
> read/fetch from 0x0000 0008 will provide data stored in 0x4000 0008."
>
> Based on this I assume that the chip will still check the flash memory
> address and not the RAM address after a remap.

Afaik 0x4000 0000 is the start of RAM, not FLASH, so by writing to those
RAM locations you can set what the interupt will read.

Wouter
kd7vn schrieb:

> Based on this I assume that the chip will still check the flash memory
> address and not the RAM address after a remap. If my assumption is
> correct I have no idea what I gain from remapping.

Again: If you want to modify the vectors you need RAM at the place where
they are.
>
> I.e. if an IRQ request comes, the processor will read/fetch from
> 0x0000 00018, and that address will have the same information that is
> in 0x4000 0018. If this is true I'm not sure what I'm getting by
> remapping.

0x40000018 can be modified w/o flashing.

> I may even be loosing something as the LPC2378 uses the PrimeCell 192
> Vector Interrupt Controller.

Yes. You will do the same ldr pc,[pc,-???] for IRQ and FIQ, but
if you have e.g. different abort handler for bootup and runtime the
easiest way if to remap.

--
42Bastian

Note: SPAM-only account, direct mail to bs42@...

I see three points to have vectors in RAM:
1) RAM is faster than FLASH (specifically for random
access). The MAM cannot help since it does not expect
the vector access. This probably only saves a fraction
of a microsecond, but it might be critical for someones
FIQ requirement.

2) If you need to service interrupts during IAP, both the
interrupt service routine and the vector must be in RAM
because FLASH is unavailable during the write cycle.

3) You can change the vectors without having to rewrite
FLASH. This might be useful but it is also dangerous.
And the VIC already allows IRQ vectors to be changed
(with a layer of protection).

Regards,
Danish
In systems that have a secondary boot loader and application co-
resident in flash, being able to remap the vectors to RAM is a must.

I did a project with a boot loader that would reprogram the
application from an SD-Card. The boot loader and the application
were compiled as separate programs. The boot loader was compiled to
start at the bottom of flash, so the vector table was in the correct
location. The application had to be compiled to start at an offset
to allow the boot loader to reside at the bottom of flash. When
compiled with this offset, the application's vector table is NOT at
the right location, so the application must copy the vector table to
RAM and set the remap bit.

Jeff
--- In l..., "kd7vn" wrote:
>
> Is there any advantage to switching the interrupt vectors from
flash
> memory to RAM (lpc 2378)? Is it needed if I plan to run my program
> out of RAM memory?
>
> This question arose when I came across the following in the user
manual.
>
> "Re-mapped memory areas, including the Boot ROM and interrupt
vectors,
> continue to appear in their original locations, in addition to the
> remapped addresses"
>
> -Markus
>