LPC1549 UART Bootloader AutoBaud fails

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

LPC1549 UART Bootloader AutoBaud fails

1,022 Views
konstantinwerne
Contributor I

Hi everyone!

I am trying to get the UART bootloader on the LPC1549 to work.

Reinvoking the ISP from user code works fine, but then the problems start:

If I put the call to reinvoke_isp directly into the main() (after all the peripherals have been initialized), autobaud works correctly and the chip answers "SYNCHRONIZED".

In this case the BRG-Register of the USART0 peripheral has a value of 0x4D after the autobaud.

But when I call reinvoke_isp later by sending a command via UART to the user code, the autobaud-routine fails and sets the BRG register to 0xAC54 which results in a veeeery slow baudrate (approx. 1.5 seconds per char).

The only difference between the two cases is that the MCU has to parse the incoming command. Everything else has been successfully initialized in both cases.

I tried resetting the USART0 peripheral before reinvoking ISP, but that didn't change anything.

The stackpointer is reset to the top of the stack-32bytes (for IAP) and the upper 32bytes of RAM are excluded from usage by the usercode. (The datasheet mentions that the ROM code uses these bytes.)

I also compared all SYSCON register values in the working and non-working case. There were no differences.

What am I missing? Do I have to initialize/reset anything else to make the autobaud routine work correctly?

Looking forward to your answers :smileyhappy:

Best regards

Konstantin

Labels (2)
0 Kudos
2 Replies

594 Views
Dezheng_Tang
NXP Employee
NXP Employee

On LPC1549Xpresso board, I ran a quick test on Reinvoke ISP on both UART and USB and didn't see any

problems though. I also tried my IAP code running in either RAM or flash, both work. A quick test you can do

is to make your application bare minimum, e.g.

(1) Only use 12Mhz IRC as MAINCLK.

(2) Enable RAM1 and RAM2, IOCON, SWM, GPIO 0/1/2 clocks in SYSAHBCLKCTRL register.

(3) Disable all interrupts.

(4) Call IAP to read part ID, and then reinvoke ISP with either USB(2) or UART(1)

If you invoke USB ISP, make sure USB is connected to the PC, on reinvoke, USB ISP should

be enumerated as Mass Storage device.

Then, try UART ISP, type "?", "Synchronized" should appear.

uint32_t ReadIdentification(void) {
  IAP.cmd = IAP_READ_PART_ID;
  IAP_Call (&IAP.cmd, &IAP.stat);
  if (IAP.stat) return (0);

  return (IAP.res[0]);
}

int ReinvokeISP (uint32_t isp_num ) {
  IAP.cmd    = IAP_REINVOKE_ISP;               // Reinvoke ISP
  IAP.par[0] = isp_num;                        // ISP number, 1=UART ISP, 2=USB ISP, 3=CAN ISP
  IAP_Call (&IAP.cmd, &IAP.stat);              // Call IAP Command
  if (IAP.stat) return (IAP.stat);             // Command Failed

  return (0);                                  // Finished without Errors
}

In the beginning of main, do something like:

  

   LPC_SYSCON->SYSAHBCLKCTRL0 |= (EN0_RAM1 | EN0_RAM2 | EN0_IOCON | EN0_SWM);

   LPC_SYSCON->SYSAHBCLKCTRL0 |= (EN0_EE | EN0_GPIO0 | EN0_GPIO1 | EN0_GPIO2);

  i = ReadIdentification();
  if ((i & 0x00001500) != 0x00001500) {
    while (1);
  }
 ReinvokeISP (UART_ISP);

0 Kudos

594 Views
konstantinwerne
Contributor I

Thank you for your answer!

I found the error! The terminal program I was using always sent a null-byte when closing....

So every time I invoked the bootloader via serial command, closed the terminal program and reopened it with another baudrate setting. By the time I send my '?' the autobaud routine has seen the null-byte and calculated a wrong value...

0 Kudos