Reinvoke ISP command - omissions from NXP docs

Started by whitewing, March 09, 2008, 10:31:48 AM

Previous topic - Next topic

whitewing

I posted this to the LPC2000 list a while ago - thought it may be useful to people here as well :
There are some omissions from the NXP UM (LPC2136/01) regarding the 'Reinvoke ISP' command in IAP (this is used to get into the bootloader where the P0.14 pin is not easily accessible)

Before making the call to start the bootloader, you need to set SCS to 0 to disable fast IO, and set U0FDR to 0 to disable the fractional baudrate divider.  I suspect the same issues apply to all parts with FIO and fractional baudrate divider.

This code (IAR) works :
__arm void startboot(void)
  {
__disable_interrupt();
   PLLCON=0;
   PLLFEED = 0xAA;
   PLLFEED = 0x55;
   SCS=0; // disable fast IO
   U0FDR=0; // no FDR - causes wrong baudrate if <>0
   asm("mov r0,#0x40000000");
   asm("mov r1,r0"); // even though no return expected, R1 MUST be initialised!
   asm("mov r2,#0x39");
   asm("str r2,[r0]");
   asm("mov r2,#0x7ffffff1");
   asm("bx r2");
}

whitewing

Just found another bug in this command - the Reinvoke ISP command does not reinitialise the SP to a place that makes sense for use when ISP is active, so if you enter with SP in an unfortunate place ( like ISP workspace, buffer that ISP is using) it falls over catastrophically during programming.
0x40000100 seems a fairly safe place to set R13 to, so add the following line to the above code, just before the bx r2 :
asm("add r2,r0,#0x100");

whitewing

A couple of further notes...
Value of U0FDR should be 0x10 ( its reset value) , not 0x00 as above. The latter value makes it not work _some_ of the time..!
I had a reply from Philips on the stack pointer issue. They acknowledged this, and suggested the SP be set to (top of RAM) -32, as this is where it gets put on a normal reset .

So the code should be :
  PLLCON=0;
  PLLFEED = 0xAA;
  PLLFEED = 0x55;
  SCS=0; // disable fast IO
  U0FDR=0x10; // no FDR - causes wrong baud
  asm("mov r0,#0x40000000");
  asm("mov r1,r0");
  asm("mov r2,#0x39");
  asm("str r2,[r0]");
  asm("mov r2,#0x7ffffff1");
  asm("add r13,r0,#0x8000"); // stack at top-32, as per Philips reccommendation LPC2136 - adjust for other processors accordingly
  asm("sub r13,r13,#0x20");
  asm("bx r2");

isisview

Thanks for posting these details.

Turning off fast io using SCS=0; has fixed my issue.

This is a clear ommision from the user manual and it would be good if NXP could rectify this.

The fix also applies to the ISP bootloader when entered from use code as outlined in the "AN10356 Entering ISP Mode from User Code, V3 (Sep 13, 2006)" app note but it doesn't mention the requirement to have fast io disabled.

Dean