在NRF LOG增加时间戳显示在RTT Viewer中

本文介绍了如何在NRF52832开发中通过get_rtc_counter函数获取RTC计数器值,并将该值用于NRF_LOG_INIT以添加时间戳。结果展示了日志记录的时间细节变得更精确。

(1) 在main .c中增加如下函数

uint32_t get_rtc_counter(void)
{
    return NRF_RTC1->COUNTER;
}

(2) main.c中改变如下函数:
原始调用如下:

uint32_t err_code = NRF_LOG_INIT();

改变之后如下:

uint32_t err_code = NRF_LOG_INIT(get_rtc_counter);

(3) sdk_config.h中改变如下宏定义:
原始宏定义如下:

#define NRF_LOG_USES_TIMESTAMP 0

改变之后如下:

#define NRF_LOG_USES_TIMESTAMP 1

(4) 修改之后的结果如下:

The result will be to change logs from this:

<info> app: Setting vector table to bootloader: 0x000F1000
<info> app: Setting vector table to main app: 0x00026000
<info> app: Buttonless DFU Application started.
<info> app: RTC 8211
<info> app: Received indication state 1
<info> app: Received indication state 0

to this:


[00:00:00.000,000] <info> app: Setting vector table to bootloader: 0x000F1000
[00:00:00.000,000] <inf
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

技术在路上

帮助需要的人

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值