Starting from this example I try to bring clock functionality to my BLE-project.
1. The external LFCLK-XTAL
I need some clarification about the use of the different clock sources on the Development Kit. I searched through the Q&A, but did not find a concrete statement about that:
(the links of this question are leading to the Q&A-start-page)
The NRF52 DK-User Guide says, that an OPTIONAL 32.768kHz Crystal X2 can be soldered to the board, which is directly connected to the GPIO Pin P0.00 and P0.01. My board has nothing soldered to this, so far so good.
In the sdk_config.h of the example projects the ClockSource for the soft device is always set to 1, which means it's clocked to some XTAL:
// <o> NRF_SDH_CLOCK_LF_SRC - SoftDevice clock source. // <0=> NRF_CLOCK_LF_SRC_RC // <1=> NRF_CLOCK_LF_SRC_XTAL // <2=> NRF_CLOCK_LF_SRC_SYNTH #ifndef NRF_SDH_CLOCK_LF_SRC #define NRF_SDH_CLOCK_LF_SRC 1 #endif
(1) All the examples are running on my board, so, which XTAL is used then?
I see that there are two Oscillators X1 (lose to the nrf52832 Bluetooth chip) and X2 (close to the ARM Cortex M4F chip) soldered to the board but I guess (2) these are the HF-Oscillators?
2. Starting/accessing the HFCLK from the soft device
I understand that the soft device is using the HFCLK and the LFCLK. According to this article the soft device is powering off the HFCLK if it's not needed by the BLE-stack but it can be enabled manually via a call to the sd_clock_hfclk_request()-function. So, if my soft device is working correctly (and from this I assume that a valid HFCLK has been selected by the soft device)
why does this code keeps stuck in the while loop / why is the HFCLK not starting?
NRF_LOG_DEBUG("requesting HFCLK via softdevice function");
sd_clock_hfclk_request();
NRF_LOG_DEBUG("checking in loop if HFCLK is running");
uint32_t * nrf_clock_running_flag = 0;
sd_clock_hfclk_is_running(nrf_clock_running_flag);
int n = 0;
while(!nrf_clock_running_flag){
if(n % 1000000 == 0) NRF_LOG_DEBUG("clock is not running: %i, while-loop: %i", nrf_clock_running_flag, n);
n++;
if(n > 10000000) n= 0;
}
NRF_LOG_DEBUG("clock is running");
PS: is there a reason why the nordic-website is so slow from Germany? Pages and Insert-Code-windows are loading really slow.