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

Timestamp problem

Hi team,

I am using sdk 12.1.0 and ble_app_hrs_c example.I enabled #define NRF_LOG_USES_TIMESTAMP 0 to 1 and iam usng nrf51822 dongle.my program gets hanged.I need to print the timestamp.I am unable to view the data from serial.please tell me what is the problem??

Parents
  • A quick and probably dirty way to get timestamps working.

    Copy counters.c and counter.h from examples/ble_central_and_peripheral/experimental/ble_app_att_mtu_throughput/ into your project.

    Then make the following code changes. Assumes using pca10040 and armgcc. But should be similar for other setups.

    --- a/main.c
    +++ b/main.c
    @@ -45,6 +45,8 @@
     #include "bsp.h"
     #include "bsp_btn_ble.h"
    +#include "counter.h"
    +
    @@ -773,7 +775,12 @@ int main(void)
         uint32_t err_code;
         bool erase_bonds;
    
    -    err_code = NRF_LOG_INIT(NULL);
    +#if NRF_LOG_USES_TIMESTAMP==1
    +    counter_init();
    +    counter_start();
    +#endif
    +
    +    err_code = NRF_LOG_INIT(counter_get);
         APP_ERROR_CHECK(err_code);
    --- /pca10040/s132/armgcc/Makefile
    +++ /pca10040/s132/armgcc/Makefile
    @@ -29,6 +29,7 @@ SRC_FILES += \
       $(SDK_ROOT)/components/drivers_nrf/common/nrf_drv_common.c \
       $(SDK_ROOT)/components/drivers_nrf/gpiote/nrf_drv_gpiote.c \
       $(SDK_ROOT)/components/drivers_nrf/uart/nrf_drv_uart.c \
    +  $(SDK_ROOT)/components/drivers_nrf/rtc/nrf_drv_rtc.c \
       $(SDK_ROOT)/components/libraries/bsp/bsp.c \
       $(SDK_ROOT)/components/libraries/bsp/bsp_btn_ble.c \
       $(SDK_ROOT)/components/libraries/bsp/bsp_nfc.c \
    @@ -122,6 +123,7 @@ INC_FOLDERS += \
       $(SDK_ROOT)/components/drivers_nrf/timer \
       $(SDK_ROOT)/components/libraries/util \
       $(SDK_ROOT)/components/drivers_nrf/pwm \
    +  $(SDK_ROOT)/components/drivers_nrf/rtc \
       ../config \
       $(SDK_ROOT)/components/libraries/usbd/class/cdc \
       $(SDK_ROOT)/components/libraries/csense \
    
    --- a/pca10040/s132/config/sdk_config.h
    +++ b/pca10040/s132/config/sdk_config.h
    @@ -3658,7 +3658,7 @@
     // <i> Function for getting the timestamp is provided by the user
    
     #ifndef NRF_LOG_USES_TIMESTAMP
    -#define NRF_LOG_USES_TIMESTAMP 0
    +#define NRF_LOG_USES_TIMESTAMP 1
     #endif
    
    --- a/pca10040/s132/armgcc/Makefile
    +++ b/pca10040/s132/armgcc/Makefile
    @@ -36,6 +36,7 @@ SRC_FILES += \
    +  $(PROJ_DIR)/counter.c \
       $(SDK_ROOT)/external/segger_rtt/RTT_Syscalls_GCC.c \
       $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \
       $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \
    
    --- a/pca10040/s132/config/sdk_config.h
    +++ b/pca10040/s132/config/sdk_config.h
    @@ -1835,7 +1835,7 @@
    
    
     #ifndef RTC2_ENABLED
    -#define RTC2_ENABLED 0
    +#define RTC2_ENABLED 1
     #endif
    
  • Hi DavidC,

    Q: this modifications that I need to do it in the makefile or in the main code?

    A: If you are using a makefile(you are in fact usign armgcc), you need to apply changes in both main code and in the makefile. All changes needed is covered in the patch snippet above.

Reply Children
No Data
Related