1.在sdk_config.h加入宏
#ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY
#define UART_DEFAULT_CONFIG_IRQ_PRIORITY 6
#endif
#ifndef NRF_CLOCK_ENABLED
#define NRF_CLOCK_ENABLED 1
#endif
#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY
#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6
#endif
#ifndef NRFX_CLOCK_CONFIG_LF_SRC
#define NRFX_CLOCK_CONFIG_LF_SRC 1
#endif
2.导入nrf_drv_clock.c和nrfx_clock.c文件到工程
3.初时化
if(!nrf_drv_clock_init_check())
{
APP_ERROR_CHECK(nrf_drv_clock_init());
printf("\nnrf_drv_clock_init\n");
}
4.请求低频时钟
nrf_drv_clock_lfclk_request(NULL);
nrf_delay_ms(100);
if(nrf_drv_clock_lfclk_is_running())
{
printf("nrf_drv_clock_lfclk_is_running\n");
}
6.释放低频时钟
nrf_drv_clock_lfclk_release();
nrf_delay_ms(100);
if(!nrf_drv_clock_lfclk_is_running())
{
printf("nrf_drv_clock_lfclk_is_stop\n");
}
7.请求高频时钟
nrf_drv_clock_hfclk_request(NULL);
nrf_delay_ms(100);
if(nrf_drv_clock_hfclk_is_running())
{
printf("nrf_drv_clock_hfclk_is_running\n");
}
8.释放高频时钟
nrf_drv_clock_hfclk_release();
nrf_delay_ms(100);
if(!nrf_drv_clock_hfclk_is_running())
{
printf("nrf_drv_clock_hfclk_is_stop\n");
}
