最近在学习NRF51822,在使用内部RC时钟时遇到无法启动的问题,设置时钟后,实际运行还是外部16M ,配置代码如下:
sta
tic void lfclk_config(void)
{
//NRF_CLOCK->EVENTS_HFCLKSTARTED=0;
//NRF_CLOCK->TASKS_HFCLKSTART=0;
//NRF_CLOCK->TASKS_HFCLKSTOP = 1;
//NRF_CLOCK->XTALFREQ = CLOCK_XTALFREQ_XTALFREQ_Msk;
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos);
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
NRF_CLOCK->TASKS_LFCLKSTOP = 0;
NRF_CLOCK->TASKS_LFCLKSTART = 1;
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
{
}
//NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
}
上面注释掉的几句代码也试过,上面的停止也好 START=0也好 都试验过,没有任何变化
参考函数为网上下载资料里面蓝牙库里的,原函数如下:
static void lfclk_config(void)
{
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
NRF_CLOCK->TASKS_LFCLKSTART = 1;
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
{
}
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
}
不过原函数也一样不管用,求解!!!!!!