nRF52 系统启动异常

在调试Nordic FreeRTOS 自己写的程序时,发现烧录到主板里,串口发送数据没反应,但是在RTT connect后就可正常输出,查阅资料后发现如下问题,修改后已经解决。

我的程序有做
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART = 1;
同时也有
nrf_drv_clock_lfclk_request(NULL)
按这位大佬说的修改后就好了(只不过我俩操作的寄存器不一样)
原文链接:https://blog.csdn.net/qq_37258637/article/details/99290820
因部分有直接操作 LFCLK 寄存器的程序:

NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos);
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
NRF_CLOCK->TASKS_LFCLKSTART = 1;
 
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
{
    //Do nothing.
}
 
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;

所以不需 nrf_drv_clock_lfclk_request(NULL) 操作,否则两个操作冲突,会导致卡在

while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
{
    //Do nothing.
}

询问了Nordic社区,他们是这样说的。
Could it be that when you connect the RTT, you also connect the UART pins? A floating UART pin (RX in particular), can cause the application to fail. Looking at the ble_app_uart example for reference, in the uart event handler in main.c, you can see that it has the event APP_UART_COMMUNICATION_ERROR, which will trigger an APP_ERROR_CHECK(err), which will reset the application.

For debugging purposes, see if you have something similar in your application, or try to disable the UART to see if the issue still occurs.
我查看了下,确实在初始化时设置是这样的 nrf_gpio_cfg_input(p_config->pselrxd, NRF_GPIO_PIN_NOPULL); 搜索了一下,许多大佬也说需要修改这个为上拉。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值