Hung up on EVENTS_HFCLKSTARTED in "Debug" build but not in "Release" build

I have created a custom board containing the nRF52832. I have two copies. The first board works, meaning that I have flashed the code to it using the DK52, and I can power it up on its own, and it runs fine.

When I connect the second board to the DK52 and I hit "Start Debugging" in Segger Embedded Studio, the program works fine when I use the "Release" configuration build. But when I use the "Debug" configuration build, I get stuck at

while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);

Neither build works when I hit "Start Without Debugging."

Is this for sure a crystal issue? Does the crystal get bypassed when debugging? I'm confused that debugging works for "Debug" build but not for "Release" build. Thanks in advance for any info.

Related