In my current project I have two type of boards. Some have the external 32kHz crystal mounted and some not.
I am trying to detect the presence of the external crystal by trying to start it and checking EVENTS_LFCLKSTARTED and LFCLKSTAT.
My code is the following :
When the crystal is connected; the MCU wait a little in the while() and later by checking LFCLKSTAT and LFCLKSRC I have the following :
LFCLKSTAT = 65537 (Src=Xtal Stat=Running)
LFCLKSRC = 1 (Src=Xtal).
Which is the expected behavior.
The problem is when I test this on the board WITHOUT the crystal, the MCU wait several seconds in the while and later by checking LFCLKSTAT and LFCLKSRC I have the following :
--> This is absolutely not the expected behavior.
I have also done the test on an NRF52840. And it never goes out of the while loop. And by checking LFCLKSTAT and LFCLKSRC I have the following :
LFCLKSTAT = 0x00 (Src=RC Stat=Not Running)
Which is expected.
Are you aware of this behavior and do you have a way to detect if a 32kHz crystal is mounted on a board with NRF52832?
I have read this ticket : https://devzone.nordicsemi.com/f/nordic-q-a/53362/how-to-check-nrf52840-external-low-frequency-crystal-32khz-is-connected-or-not
But waiting more that 250µS doesn't seem to be a reliable way to detect the absence of crystal. Especially if after some time the MCU state it is running on LFXO even if it is not mounted on the board.
We suspect that the noise injection on XL1(P0.00) and/or XL2(P0.01) could be enough to trigger the event EVENTS_LFCLKSTARTED, and be propagated to the clock output even if no crystal is mounted, and even…
I was not able to reproduce this on a nRF52832DK without LF crystal.
But, could you try to add this errata 132 delay, before starting the LFCK, and see if it fixes the issue? Similar to how it's done here.
I have just tested your fix and it doesn't change anything.
My code :
If I hit the reset button on a board without 32kHz crystal it boot in approx. seconds.
Also I have noticed something on boards with a crystal :
Just after flashing, crystal startup time takes more than 250ms, between 380ms and 500ms. After reset the 32kHz crystal start in 250ms. Is this something expected ?
I tested this on two other pca10040 and I can reproduce on both of them.
Marking on NRF52 is nrf52QFAAB0. Maybe you tested on an earlier revision?
I was able to reproduce this on a different nRF52832 DK.
I will check with the team if they have seen this before.
Did you get any answers from your team ?