51及52系列内部RC及外部XTAL晶振配置:
ble_stack_init --> nrf_sdh_enable_request --> clock_lf_cfg -->
内部RC(51系列16Mhz 52系列32Mhz):
#define NRF_SDH_CLOCK_LF_SRC 0
#define NRF_SDH_CLOCK_LF_RC_CTIV 16
#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 2 (51系列为1)
#define NRF_SDH_CLOCK_LF_ACCURACY 1
外部XTAL(高精度32.768Khz):
#define NRF_SDH_CLOCK_LF_SRC 1
#define NRF_SDH_CLOCK_LF_RC_CTIV 0
#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 0
#define NRF_SDH_CLOCK_LF_ACCURACY 7
or sdk_config.h --> Configuration Wizard --> nRF_SoftDevice --> NRF_SDH_ENABLED --> Clock 选择对应设置
51系列32Mhz晶振配置:
NRF_CLOCK->XTALFREQ = 0xFFFFFF00;
NRF_CLOCK->XTALFREQ = 0xFFFFFF00U;
// Start the external high frequency crystal
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART = 1;
// Wait for the external oscillator to start up
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {}