Entering LPC1343 ISP Mode (UART) from user code

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Entering LPC1343 ISP Mode (UART) from user code

929 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Terje on Wed Apr 25 05:08:26 MST 2012
[FONT=Arial][SIZE=5][FONT=&quot][SIZE=4]Do anyone know of an example of how to do this?
I found this example :
http://www.lpcware.com/content/blog/calling-lpc11xx-isp-user-code

My unit might enter ISP mode after using this routine (I loose contact with it in LPCXpresso), but I am not able to connect to it using Flash Magic. I have no problems if I start up in ISP mode pulling P0.1 low (P0.3 is permanently connected to GND) so the connection and settings in Flash Magic should be okay[/SIZE][/FONT][/SIZE][/FONT][FONT=Arial][SIZE=5][FONT=&quot][SIZE=4]
[/SIZE]
[/FONT][/SIZE][/FONT]
0 项奖励
回复
5 回复数

782 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon May 21 15:15:02 MST 2012
Of course (as mentioned in user manual), all interrupts has to be disabled before IAP is used :eek:

Since this code is original LPC11xx code, it's disabling all 32 LPC11xx interrupts :rolleyes:
0 项奖励
回复

782 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Terje on Mon May 21 14:38:52 MST 2012
[FONT=Calibri]Thanks for your help Zero.[/FONT]

[FONT=Calibri]Your application worked fine as stand alone, but it was not working in my application. It turned out to be because I use GPIO interrupt which is not getting disabled. When including "NVIC->ICER[1] = 0xFFFFFFFF;" it works.[/FONT]
0 项奖励
回复

782 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Apr 25 07:29:57 MST 2012

Quote: Terje
Any ide of what it can be?



No, resetting UART and IAP57 is working fine here :eek:

Switching from FlashMagic-Terminal to FlashMagic-ISP via '[B][COLOR=Magenta]i[/COLOR][/B]' key (PIO0_3 low) is no problem

//IAP
#define IAP_ADDRESS 0x1FFF1FF1
unsigned param_table[5]; unsigned result_table[5];
void iap_entry(unsigned param_tab[],unsigned result_tab[])
{
 void (*iap)(unsigned [],unsigned []);
 iap = (void (*)(unsigned [],unsigned []))IAP_ADDRESS;
 iap(param_tab,result_tab);
}

//call ISP
void call_ISP(void)                //call ISP via IAP
{
 NVIC->ICER[0] = 0xFFFFFFFF;    //disable all interrupts
 param_table[0] = 57;            //IAP command
 iap_entry(param_table,result_table);
}

static void StopUART(void)
{
  uint32_t temp;

  /* Disable UART interrupts */
  LPC_UART->IER = 0;
  /* Disable UART interrupts in NVIC */
  NVIC_DisableIRQ(UART_IRQn);

  /* Ensure a clean start, no data in either TX or RX FIFO. */
  while (( LPC_UART->LSR & (LSR_THRE|LSR_TEMT)) != (LSR_THRE|LSR_TEMT) );
  while ( LPC_UART->LSR & LSR_RDR )
  {
   temp = LPC_UART->RBR; /* Dump data from RX FIFO */
  }
  /* Read to clear the line status. */
  temp = LPC_UART->LSR;
}

void read_input(char in_data)            //read input from UART/USB
{
 switch(in_data)                        //switch char
 {
  case('a'):printf("Alive \n\r");
  case('b'):printf("Still Alive\n\r");
             break;
 [COLOR=Magenta] case('i')[/COLOR]:printf("Call ISP\n\r");
              timer=0;
              while(timer<1000){;}        //wait 1 second to get previous message transmitted
          [COLOR=Red]    StopUART(); [/COLOR]                   //reset UART
            [COLOR=Red]  call_ISP();  [/COLOR]                  //run ISP
              break;
  default:    break;
 }
}

0 项奖励
回复

782 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Terje on Wed Apr 25 06:02:01 MST 2012
Thanks for the reply Zero.
I am using "Reinvoke ISP" and PIO0_3 is permanently connected to ground which should select UART
I had not changed the stack, thanks for reminding me. However I am still not able to connect with Flash Magic.
The code I use is similar to the one I linked in my first post. The only change I have made was to declare all IAP data as global, as described in the example for ISP-USB.
Any ide of what it can be?
0 项奖励
回复

782 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Apr 25 05:34:36 MST 2012
That's explained in UM :rolleyes:


Quote:

21.14.8 Reinvoke ISP Table 342. Reinvoke ISP
Command Input None Result None.
Command code: 57 (decimal)

This command is used to invoke the bootloader in ISP mode. It maps boot vectors, sets PCLK = CCLK, configures UART pins RXD and TXD, resets counter/timer CT32B1 and resets the U0FDR (see Table 209). This command may be used when a valid user program is present in the internal flash memory and the PIO0_1 pin is not accessible to force the ISP mode.

So this command is working like Reset & ISP pin low and starting your ISP bootloader. If your chip has 2 of them, PIO0_3 is deciding which one will be started.

But don't forget to change your stack: http://support.code-red-tech.com/CodeRedWiki/ReserveIAPRam
0 项奖励
回复