Hello everyone,
I’ve been using the XIAO BLE nRF52840 for a few months now, and I’ve had great success. This forum has been incredibly helpful in resolving various issues, including battery management.
Thank you for this great community.
I programmed the board using Zephyr OS and have been successfully utilizing Bluetooth Low Energy features, including pairing and all other functionalities. I’ve also been working with GPIOs, PWM, ADC, the Watchdog timer and various other features.
However, I’ve encountered a significant issue. The board occasionally stops functioning for 20 minutes to multiple hours. During these periods, the firmware fails to boot, but the bootloader remains operational. After a random amount of time, sometime after several hours, the board will reboot itself, and everything will work magically again.
- This problem was present in my firmware with Zephyr OS, as well as in a Zephyr OS blink example.
- Interestingly, the UF2 bootloader was not affected by this issue. The remote drive appears on my computer, the LED works, and everything else functions correctly.
- Additionally, an Arduino Code blink example using the Arduino IDE was also free from this problem.
I can now say that it is likely that my own C code is not the culprit.
Given these observations, the question now arises: why does Zephyr OS occasionally and unpredictably fail to boot?
I’ve discovered a potential solution, and I’m 90% certain it works. However, due to the intermittent nature of the issue, I’m waiting to gather more data to confirm the fix definitively.
Using the internal RC clock instead of the external 32Khz crystal seems to fix the problem.
To address this issue, I made the following changes in my prj.conf file.
These configurations instruct Zephyr OS to use the RC oscillator as the clock source (instead of crystal oscillator). They specify that the RC oscillator is precise to 500 ppm (as per the nRF52840 datasheet) and enable automatic calibration of the RC clock.
# Clock (the external crystal is instable. Use the internal RC.)
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION=y
CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_LF_ALWAYS_ON=y
I’m not an expert in electronics crystal oscillators, but I understand they’re highly sensitive and can cause erratic behaviors.
Does anyone here have more knowledge about this issue? Is there a more reliable solution than relying on the internal RC clock of the chip? How can I fix the external crystal?
Maybe the problem is something else. In theory this bug shouldn’t exist, otherwise the problem would be known.
So, most probably the problem is something else unrelated.
Debugging these bugs is quite hard.
I appreciate all your help.
Some facts:
- When I refer to “board,” I mean the XIAO BLE nRF52840 black PCB that has been soldered onto another PCB with various components.
- The bug appears at different times on different boards. I’m not sure how to interpret this.
- Some boards have never shown the bug.
- Some boards show the bug once every two weeks.
- Some boards show the bug once every day.
- Some boards show the bug once every hour.
Perhaps our soldering process has damaged the board? It would be surprising because the soldering process is quite quick and painless. Alternatively, the flux I use to solder boards might infiltrate the shield and cause damage.