EmbeddedRelated.com
Forums

IAP Reinvoke ISP command - yet another omissions from documentation

Started by Mike Harrison May 16, 2008
Just tracked down another issue with "reinvoke ISP" that I just wasted another few hours finding,
further to my post below a while ago.....
This is on LPC2136/01 but probably applies to many other parts

The "Reinvoke ISP" IAP command does not reinitialise the SP (R13) 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, or the
buffer that ISP is using) it falls over catastrophically during programming. Obviously you have
little control of where SP will be pointing to when calling from C, so it should be set explicitly.
0x40000100 seems a fairly safe place to set R13 to.

I've amended the code below from the original post.
Subject: IAP Reinvoke ISP command - omissions from documentation
From: Mike Harrison
Date: Thu, 14 Feb 2008 11:13:44 +0000

I've just spent some time figuring out why I couldn't make the IAP 'Reinvoke ISP' command working on
LPC2136/01 - hope this saves others from the same struggle - I will notify Philips that they should
update their UM.

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"); // although no return expected, R1 must be initialised
asm("mov r2,#0x39");
asm("str r2,[r0]");
asm("mov r2,#0x7ffffff1");
asm("add r13,r0,#0x100"); // set up stack in safe place
asm("bx r2");
}

An Engineer's Guide to the LPC2100 Series

Reply from NXP :

thanks for bringing this up. I can confirm the need to initialize R13
upon calling 'Reinvoke ISP' command. You should set R13 to 'Top of
SRAM - 32', as this is the value used after power up. (For LPC2136:
0x40007FE0)

I will issue a change request for the documentation.

--- In l..., Mike Harrison wrote:
>
> Just tracked down another issue with "reinvoke ISP" that I just
wasted another few hours finding,
> further to my post below a while ago.....
> This is on LPC2136/01 but probably applies to many other parts
>
> The "Reinvoke ISP" IAP command does not reinitialise the SP (R13) 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, or the
> buffer that ISP is using) it falls over catastrophically during
programming. Obviously you have
> little control of where SP will be pointing to when calling from C,
so it should be set explicitly.
> 0x40000100 seems a fairly safe place to set R13 to.
>
> I've amended the code below from the original post.
> Subject: IAP Reinvoke ISP command - omissions from documentation
> From: Mike Harrison
> Date: Thu, 14 Feb 2008 11:13:44 +0000
>
> I've just spent some time figuring out why I couldn't make the IAP
'Reinvoke ISP' command working on
> LPC2136/01 - hope this saves others from the same struggle - I will
notify Philips that they should
> update their UM.
>
> 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"); // although no return expected, R1 must be
initialised
> asm("mov r2,#0x39");
> asm("str r2,[r0]");
> asm("mov r2,#0x7ffffff1");
> asm("add r13,r0,#0x100"); // set up stack in safe place
> asm("bx r2");
> }
>