LPC824: Why can I program the device just once?

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

LPC824: Why can I program the device just once?

1,480 Views
rmikkers
Contributor I

I have recently made a pcb with a LPC824M201JDH20 on it. The first time I can program a .hex file into the microcontroller by using Flash Magic ISP. Actually if I try to do it the second time, it will not work anymore. Flash Magic gives an autobaud error. If I look at the signals(ISP reset, ISP enable, ISP TX) to the microcontroller, the signals are right. Actually there is no rx signal, so the LPC824 is not responding.

 

It looks like the LPC824 is coming into CRP mode. This because I can read the device until I do a powercycle. This CRP mode protects the device from re-writing a .hex file. Actually how can I turn this mode off or set it in a state that I can reprogram the controller? And is my interpretation on this related to this CRP mode correct, or do I have to look at something else?

 

In settings the CRP is unchecked and also crp.c says "CRP_WORD = CRP_NO_CRP".

 

Can you help me with this?

Labels (1)
Tags (1)
0 Kudos
Reply
2 Replies

897 Views
thefallguy
Contributor IV

Your code is probably putting the chip into a 'strange' state. Suggest that you read this FAQ for further information:

Regaining debug access to target MCU

0 Kudos
Reply

897 Views
rmikkers
Contributor I

Hello Fall Guy,

Thanks for the answer on my question. I finally worked out how to fix the problem. My chip was not in the CRP mode. The work around to this code is to add the following code.

void configurePins()

{

  /* Enable SWM clock */

  //  LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 7);  // this is already done in SystemInit()

  /* Pin Assign 8 bit Configuration */

  /* U0_TXD */

  /* U0_RXD */

  LPC_SWM->PINASSIGN[0] = 0xffff0004UL;

  /* Pin Assign 1 bit Configuration */

  #if !defined(USE_SWD)

    /* Pin setup generated via Switch Matrix Tool

       ------------------------------------------------

       PIO0_5 = RESET

       PIO0_4 = U0_TXD

       PIO0_3 = GPIO            - Disables SWDCLK

       PIO0_2 = GPIO (User LED) - Disables SWDIO

       PIO0_1 = GPIO

       PIO0_0 = U0_RXD

       ------------------------------------------------

       NOTE: SWD is disabled to free GPIO pins!

       ------------------------------------------------ */

    LPC_SWM->PINENABLE0 = 0xffffffbfUL;

  #else

    /* Pin setup generated via Switch Matrix Tool

       ------------------------------------------------

       PIO0_5 = RESET

       PIO0_4 = U0_TXD

       PIO0_3 = SWDCLK

       PIO0_2 = SWDIO

       PIO0_1 = GPIO

       PIO0_0 = U0_RXD

       ------------------------------------------------

       NOTE: LED on PIO0_2 unavailable due to SWDIO!

       ------------------------------------------------ */

    LPC_SWM->PINENABLE0 = 0xffffffb3UL;

  #endif

}

This is to make sure the pins are correctly configured.

Thanks for the help anyway!

0 Kudos
Reply