EDIT:
I'm using nRF51422-QFAA E00 and S310 v1.0.0, SDK - nRF51 5.2.0.
I'm starting HFCLK from externall crystal for ADC conversion. Since I have no SD enabled everything is OK, but within SD and using function sd_clock_hfclk_request() problem appears. It simmply stuck in the loop where sd_clock_hfclk_is_running(&tmp) is checked -> still returning 0. Enabling SD I have same as in examples and if I try the other SD funcs (like sd_temp_get()) they works ok. Example project with BLE and ANT works ok - I can see broadcast.
I tried to recompile project with S210 v 3.0.0 with same behaviour. I can't see in PAN doc any problem about that for my revision.
Here is my code for hfclk start for SD and non SD use:
void V_hw_HFClock_Enabled(void)
{
u32 p_is_running;
// XTALFREQ is set by UICR (16MHz default)
/* Start 16 MHz crystal oscillator */
#ifdef NO_SD
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART = 1;
/* Wait for the external oscillator to start up */
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {}
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
#else
(void)sd_clock_hfclk_request();
do {
sd_clock_hfclk_is_running(&p_is_running);
}while(p_is_running==0);
#endif
}
void V_hw_SD_Setup(void)
{
u32 err_code;
err_code = sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, softdevice_assert_callback); // ABS06-32.768kHz-9-T +-20ppm
if(err_code != NRF_SUCCESS) V_error_handler(E_SD_EN);
err_code = sd_nvic_SetPriority(SD_EVT_IRQn, NRF_APP_PRIORITY_LOW);
if(err_code != NRF_SUCCESS) V_error_handler(E_SD_SP);
err_code = sd_nvic_EnableIRQ(SD_EVT_IRQn);
if(err_code != NRF_SUCCESS) V_error_handler(E_SD_EI);
}
main loop:
V_hw_SoC_Init();
sd_temp_get(&p);
tmp2 = sd_clock_hfclk_request();
if(tmp2 != NRF_SUCCESS) NRF_GPIO->OUTSET = (1UL << LED);
do {
tmp2 = sd_clock_hfclk_is_running(&tmp);
if(tmp2 != NRF_SUCCESS) NRF_GPIO->OUTSET = (1UL << LED);
}while(tmp==0);
NRF_GPIO->OUTSET = (1UL << LED);
LED is still OFF, so no error and can't get out of loop (unitl WDG after 2sec made a reset).
I don't know why it works when I'm not using SD and start HF CLK with registers and why not with enabled SD and HF start by SD funcs. I have attached HF CLK XTAL 16MHz (NX2520SA) startup if someone can compare for startup time.