SDK15.3通过RTT打印出带时间的log

This will achieve adding time-stamps to NRF logs, in some of the nRF example applications.

1. Add this to main .c

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

2. Change this in main.c

uint32_t err_code = NRF_LOG_INIT();

to this

uint32_t err_code = NRF_LOG_INIT(get_rtc_counter);

3. Change sdk_config.h

from this

#define NRF_LOG_USES_TIMESTAMP 0

to this

#define NRF_LOG_USES_TIMESTAMP 1

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] <info> app: Setting vector table to main app: 0x00026000
[00:00:00.440,002] <info> app: Buttonless DFU Application started.
[00:00:00.440,032] <info> app: RTC 14419
[00:00:22.580,566] <info> app: Received indication state 1
[00:00:30.905,548] <info> app: Received indication state 0

 

参考博客:

https://devzone.nordicsemi.com/f/nordic-q-a/23662/how-to-add-timestamp-in-rtt-viewer-using-nrf-log-module

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值