Seem to have "lost" my LPC812

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by wrighflyer on Mon Jan 28 11:25:35 MST 2013
I made a mistake in programming my LPC812 in that I added the following line to the startup code:
    /* Pin Assign 1 bit Configuration */
    /* ACMP_I1 */
    /* SWCLK */
    /* SWDIO */
    /* RESET */
    LPC_SWM->PINENABLE0 = 0xffffffb2UL;
0x1B2 is not the right value it turns out. In the debugger I saw this line lose connection several times and when I inspected the register the power on default was actually 0x183 so I should have been setting it to 0x182 to only change the analog comparator which was the aim. Incidentally the "Switch matrix" tool from NXP generated this wrong code. But that's incidental.

So to correct this I stopped debugging and changed the source then tried to start debugging again but whatever I try I cannot make it connect. I see the red LED on the debugger part of the board flash and the green LED on the LPC812 side momentarily goes off but then lights again. So it's like the CPU is being reset but it restarts and sets that register which disconnects the debugger before the debugger can "catch it".

So it looks like I screwed the SWD link. So how do I get back from here?

I've read other threads that mention "flashmagic" and that involves connecting up UART RX/TX pins to a USB-RS232 and holding a pin low after reset. But is that the only thing I can do. Is there nothing in the Code Red IDE I can do to tell the debugger to give some kind of "hard reset" to stop the debugged CPU from starting?

I'm kind of hoping I can do this without having to wire up UART etc. but I have a sneaking suspicion that it maybe cannot be avoided?

(shame the datasheet does not have some kind of strong warning about the consequences of simply writing the wrong value to the PINENABLE0 register!)