This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Log Timestamp issues NRF52

Hello!

Recently I was asked to find a way to enable timestamps in our debug logs to make it easier to track performance during various stages of the operation of our device.

I found a few blog posts detailing the process and saw that you have to enable NRF_LOG_USES_TIMESTAMP in the sdk_config.h file. I enabled that, expecting that to be the end and now when I start up my debug session the device hardfaults and doesn't run the program. 

Doing a little more digging I found the following blog post https://devzone.nordicsemi.com/f/nordic-q-a/43701/logging-with-timestamp-on-sdk-15-2. It instructs the questioner to enable NRF_LOG_USES_TIMESTAMP, as I did, and then NRF_LOG_INIT(app_timer_cnt_get), which I changed my code to run. Unfortunately this didn't fix the hardfaulting issue. 

 

As soon as I set NRF_LOG_USES_TIMESTAMP to 0 as it was before my program runs as expected. What step am I missing to enable the timestamp?

For reference

I am on SDK version 17.0.2

my chip is an nrf52832

I am developing using Segger Embedded studio and hope to be seeing the timestamps in it's built in terminal. 

Thanks in advance, please let me know if you need any additional information.

  • Hi

    What are you using as the timer for these timestamps? Please check where this app_timer_cnt_get() function is defined in your application and make sure that it's not using a timer or counter instance that is used elsewhere in your application. What kind of project is it that you're trying to add timestamping to?

    Best regards,

    Simon

  • Hello,

    I suppose I didn't realize the need to select a timer for the timestamps. I had left the NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY as 0 to indicate that I wanted to use the app_timer frequency and figured that would be enough. How should I go about selecting a timer to use? 

    app_timer_cnt_get() is defined as follows in my code:

    uint32_t app_timer_cnt_get(void)
    {
        return drv_rtc_counter_get(&m_rtc_inst);
    }

    I built my project on top of the ble_app_hrs_nfc_pairing_pca10040_s132 example found in the SDK's experimental folder. We are pairing a mobile device to the nrf52832 and it is going much slower with our custom mobile app than with the nRF Connect mobile app. Essentially I was hoping to to add timestamps to our devices debug log in order to figure out what steps of our connection process are taking the longest and provide feedback to the app developers as to where to look to improve their connection speeds. 

  • Hi again

    That seems to be correct as well, can you check what this define is set to in your sdk_config.h file as well NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED. If it's set to 0, try setting it to 1 to enable the Timestamp format when logging. Also, make sure the nrf_cli.c and .h files are included in your project.

    If that doesn't help either, try to debug to find the reason for this hardfault. You can use the ble_app_att_mtu_throughput or ble_app_cli applications as reference, as they already support logging with timestamps.

    Best regards,

    Simon

Related