Changing the vector table in LPC1227

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing the vector table in LPC1227

1,630 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Vinicius Garcia on Fri Nov 08 04:50:49 MST 2013
Hi,

I´m constructing a bootloader for LPC1227 using IAR.
I made the application and boot. Both are running ok. However, after change the firmware (by bootloader app) the LPC1227 doesn´t start. This occur because I don´t know how to move the vector table.
The linker line define symbol __ICFEDIT_intvec_start__ don´t accept a value differ from 0x0000.
I need to change the vector table in IAR. Anyone knows how to do it?

Labels (1)
0 Kudos
Reply
4 Replies

1,297 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dariush_abbasi868 on Sun Dec 28 06:01:46 MST 2014
Is this  same for lpc1768 or not?
0 Kudos
Reply

1,297 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rmilne on Fri Aug 01 06:26:59 MST 2014
Using the __ramfunc directive to improve ISR performance requires that all functions called inside the ISR also be built with the same directive.  This includes any Lpcopen library routines.
0 Kudos
Reply

1,297 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by embd02161991 on Thu Feb 06 11:18:27 MST 2014
Hi
Vinicius ,

Define a function say CopyInterruptToSRAM :

void CopyInterruptToSRAM(void)
{
unsigned int * flashPtr, * ramPtr;
  unsigned int * uLimit = (unsigned int *) 0x200; 

ramPtr = (unsigned int *)0x10000000;//load RAM starting at 0x10000000, 
flashPtr = (unsigned int *)0x00;//start of interrupt vector table
  while(flashPtr < uLimit)
{
*ramPtr = *flashPtr;
ramPtr++;
flashPtr++; 
}
}


And insert these statements in main() :
CopyInterruptToSRAM();//remap interrupt vector to SRAM
SCB->VTOR =0x10000000;
LPC_SYSCON->SYSMEMREMAP = 0x01;//change memory map 


This works in any IDE including IAR.

You also need to change the location of the C file to SRAM that uses these interrupts.
This can be done in IAR by using the compiler directive __ramfunc .
For example :
__ramfunc void SysTick_Handler(void)
{
LPC_GPIO_PORT->NOT0 = (1<<7);
}


For more information on this refer the application note on IAP for LPC800 :
http://www.lpcware.com/content/nxpfile/an11388-using-lpc800-application-programming


Thanks

NXP Technical Support
0 Kudos
Reply

1,297 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by denn4208 on Mon Nov 11 11:43:06 MST 2013
Are you using interrupts in the bootloader?  if not then you don't need to move the vector table.

In the boot loader you need to add redirection for each of the interrupts
The location will depend on the start address of your main application.
void NMI_Handler(void)
{
  /* Re-direct interrupt, get handler address from application vector table */
  asm volatile("ldr r0, =0x3008");  <--- new address to jump to when interrupt is received
  asm volatile("ldr r0, [r0]");
  asm volatile("mov pc, r0");
}


if you really do need to move the vector table then the only way to to that with the lpc1227 is to remap the vector table to the start of ram

int32_t vector_in_ram[128] __attribute__ ((section ("vtable"))); // variable to hold the interrupt vectors



__disable_irq();
 // remap the interrupt vectors to the start of the code loaded in memory
    int32_t *p = (int32_t *) 0x3000;  <---- address of the start of your main application
    int i;
    // copy the interrupt vector table on base RAM
    for (i=0;i<128;i++)
    {
      vector_in_ram = *p;
      p++;
    }
    LPC_SYSCON->SYSMEMREMAP = 0x1;  // remap the interrupt vectors to ram
    __enable_irq(); // enable interrupts


I am using Code Red not IAR so there may be some differences, but these two approaches have worked for me
0 Kudos
Reply