Hello jesmith,
At start, the SWD pins are input mode and floating. When the chip comes out of reset, a small bootloader runs to prepare the hardware blocks and check the CRP (code read protection) bits. If allowed by the CRP code, it sets the PIO0_10/11 FUNC bits to select SWD function, no pull-ups or pull-downs. It then starts the user code in flash.
To allow dual use of PIO0_10 and PIO00_11 there are several options:
- have a large enough time window between the start of user code and changing the FUNC bits of the SWD pins, to allow the SWD programmer to halt the ARM core before the firmware disables SWD. Possibly an extra delay loop is needed. Both SWD pins and nRESET pin must be connected to the LPC-LINK2 or other SWD dongles.
- read the state of a PIO pin(s) at startup and use that to conditionally enable SWD
- use CRP2 mode: when PIO0_1 (ISP pin) is low during boot, the bootloader will erase the flash and enable SWD
- when using NFC and the "msg" handler from the SDK:
set MSG_ENABLE_PREPAREDEBUG to 1. (see app_sel.h and mods/msg/msg.c)
When the corresponding NFC message is received, the handler code enables SWD and goes in a wait loop.
In the demo applications this setting is done in "app_sel.h" if DEBUG is defined.
*NOT* to be used in final firmware (Release build) as it defeats the purpose of code read protection and enables wireless denial of service.
Kind regards,
Patrick