NRF52832 Jlink Debugging Zephyr application is impossible.

I have inherited a NRF52832 design, it uses Zephyr and I am using the NRF52 DK to debug the design using the SWDIO and SWDCLK.
The board flashes correctly and I can single step the debugger all the way through the Zephyr initialisation code until it wants to jump to the main thread.

This is when the debugger loses connection and cannot recover.

The code I am using uses the SAADC and a timer to sample analog inputs. I think that the SAADC and timer is somehow interfering the the debugger by flooding the interrupt.
I assume that jumping to the main thread enables all the interrupts so the debugger works until interrupts get enabled.

The program will run without the debugger so I have added a check to see what interrupts are enabled when main starts.

00> *** Booting Zephyr OS build v3.3.99-ncs1-2 ***
00> == IRQs enabled right after boot ==
00> 0 POWER_CLOCK en=1 pend=0 act=0 prio=2
00> 6 GPIOTE en=1 pend=0 act=0 prio=6
00> 7 SAADC en=1 pend=0 act=0 prio=2
00> 17 RTC1 en=1 pend=0 act=0 prio=2

I dont understand why SAADC is enabled, it should be initialised after main starts, the saadc configuration is set and the timer set for the sample rate.


Can anyone help or offer ideas to get the debugger working?

NRF52832
NRF52DK
Windows 11
NRF Connect For Desktop 2.5.0
ncs v2.4.2

  • Hi,

    Can you share some information on your custom board? Particularily, if it has the optional 32.768 kHz oscillator and the optional DCDC inductors in place? The DK board files enabled both DCDC and LFXO and if your custom board files do too, tha tcould be a problem (which we see quite often).

    To disable the DCDC add CONFIG_BOARD_ENABLE_DCDC=n (or even better, don't set it to y in the board fiels if the inductors are missing). To use LFRC instaed of LFXO, use CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y.

  • Thanks Einar,

    I think I have found the answer. We drive LEDS on the PWM outputs. The dts file configures the pwm outputs with nordic,invert.

    ChatGPT:-

    If adding nordic,invert caused the debugger to drop, that’s often because:
    • All pins went active at init (due to inverted logic) and dumped current into LEDs/FETs → brownout → reset.
    • When the driver released the PWM, the “inverted idle” held pins in an unexpected state.


    I have removed nordic,invert and the debugger now runs into main and stops, single steps etc.

Related