I seem to have a knack for getting devices into a state where I can't access them with a debug interface. Usually I'm able to do a mass erase with a P&E Cyclone, but today I've bricked two MK02FN64s to the point that I had to just replace them.
Whenever I've brought this up, support has told me that it must be because I'm changing pin or clock configurations too fast. The boards I'm having trouble with don't reuse any SWD pins so that leaves only the clock. On this particular board it switches at startup from the FRO to the PLL at 60 MHz.
To give the debugger time to connect, I added a simple loop before the clock and pin init functions. That made things worse; I think it must have gone into a watchdog reset loop, because that's when I bricked the second MCU.
What's the recommended way to guarantee that the SWD debugger is always able to connect on startup? The watchdog on this thing is set pretty slow, like maybe half a second, so I'm surprised that it takes the debugger longer than that.
I really miss the old, simple BDM debuggers where the debugger had control from the first clock cycle and it could always recover a chip.
Thanks,
Scott