NRF52832 clock driver for SDK 15.2.0
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"); }