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

Chip freezes in normal operation, but no problem when debugging

Hi all,

I recently encounter this strange issue that I couldn't understand. My code works perfectly fine during debugging on all 52832 chips, but freezes without response from time to time on some of the chips if run without debugging. When freezing, current keep in 2.68mA.

It was hard to determine the root cause, because changing a small portion of the code that seems unrelated to other will cause the chip to freeze on other location. I am not sure which part of the code cause the issues, so it is difficult to post the problematic code and the complete code is too long. I know it sounds confusing, so I will describe as in details as I could.

At the beginning: I have several Custom Boards with same design. And each board has a BUTTON input pin and a LEVEL input pin. Changing the state of BUTTON input or LEVEL input will each trigger different, unrelated functions. After the beginning, I use GPIOTE_IN_EVENT[0] interrupt for BUTTON pin detection and a timer interrupt for LEVEL input pin measurement (read NRF_GPIO->IN).

Click BUTTON->trigger a function;

LEVEL input goes high->a function in while loop in scheduler run as long as input is;

LEVEL input goes low -> a different function will run once then soon enter power_manage().

Issue 1: First, I completed the application and no problem running the code on Custom Board A, then I burned the code into Custom Board B, C, D….. ,etc, and after LEVEL input goes low and enter power_manage(), those Custom Board would run for a short time (length differ from each run) then freeze at the end of random timer interrupt.

Then, I tried comment out functions calls line by line to locate the issue. To my surprise, if I replace GPIOTE_IN_EVENT with GPIOTE_PORT_EVENT for BUTTON detection, it will solve the freezing issue on LEVEL input pin going low. But they supposed to be unrelated, and I clear the GPIOTE interrupt with NRF_GPIOTE->EVENTS_IN[0] = 0 and NRF_GPIOTE->EVENTS_PORT = 0 with each pin interrupt

Issue 2: However, the new code runs fine with LEVEL input low, will now freeze some of the chips when LEVEL input pin going high (it didn’t happen earlier). It will freeze in the scheduler function. If I slightly change the function in scheduler (say adding a few SEGGER_RTT_WriteString() calls here and there), then the freezing location within that function will change randomly, too. It sometimes even freeze during nrf_delay_ms(). Same with Issue1, this didn’t happen right after Level input changes, it always happened in a few random seconds even much longer delays.

This Issue2 happen in some, but not all Custom Boards that has issue1, and the rest boards has neither issue1 nor issue2.

They all runs fine when in debugging, issues only happen without debugging mode. Any ideas?

Related