This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SWD causing undesirable reset

Hello

I have an nRF51822 serving as s supervisory micro for an embedded Linux board. Two GPIO pins from the main CPU are hooked up to the nRF51822 to implement SWD for the purpose of upgrading the nRF.

I have written all the SWD code and the upgrade mechanism works fine, all except for one thing....

Occasionally, maybe one of of 10 times, the DIF does not appear to switch out of normal mode and the nRF seems to see the first changes on the SWDIO line as a reset.

The reason I believe their is a reset happing is that one of the GPIO pins I am monitoring changes from output to input.

I send a preample of:

  • Drive SWDIO line high. (it is already high anyway).
  • Send 150 strobes on SWDCLK, ending with SWDCLK high. Since this is driven by software, the frequency is 1.7MHz, but there are some stalls.
  • Send JTAG->SWD magic code. This is what occasionally triggers the reset.
  • Send 150 more 1 bits. ...

Even though the JTAG to SWD code triggers a reset, the device still enters debug mode and access to the internal debug is fine. It appears that the DIF is passing though the SWD signals, yet it still triggering a reset.

Are there any subtleties to getting the DIF to correctly leave Normal mode?

Parents Reply Children
  • Thanks, but there seems more to it than that. This does not appear to be deterministic.

    I think it would be good to clarify the documentation. The documentation seems to imply that this will not cause a reset.

    What seems strange to me is that I don't always see it causing a reset.

    I have code that does this:

    Enter debug mode. Fiddle some registers. Exit debug mode (ie. enable reset) Force a reset by holding SWDIO and SWDCLK low for approx 10msec. Release IO pins so that SWDIO/RESET goes high and SWDCLK stays low.

    If I run this program multiple times (eg. 1/second) I see the RESET during the preamble only about once per ten times.

  • I'm seeing a similar problem all the time.

    When I have the Black Magic Probe (SWD programmer connected), it drives both SDIO and SWCK low in its initialisation sequence, however it appears that driving SDIO low causes my nRF51 to immediately reset and also Halt its operation.

    If I disconnect the SDIO line from the programmer and manually pull it low, it also resets and halts the processor.

    The work-around appears to initially drive SDIO high, as the evaluation board I'm using does not pull this pin high or low (i.e its floating) www.waveshare.com/.../Core51822-Schematic.pdf

    However from what I have read, I thought that both SDIO and SWCK are supposed to be pulled low - or perhaps its just SCK that is supposed to be pulled low (as this is the configuration on my evaluation board)

Related