hello,
i am using sdk 16 with nrf52832 is it possible to print system time using nrf log?
thanks and regards
manikandan v
hello,
i am using sdk 16 with nrf52832 is it possible to print system time using nrf log?
thanks and regards
manikandan v
Not quite sure wht you'e after here?
It's just a number - so can be "printed" like any other number?
Or is the question actually how to obtain "system time" ?
thanks for your reply yes how can i obtain the system time??
thanks and regards
manikandan v
Remember that this is an embedded microcontroller system - it has no knowledge of "system time" unless you provide the code to do it.
(if you're not familiar with embedded microcontroller systems, nRF52 is probably not a good place to start)
You will probably want to use the internal RTC (Real Time Counter):
If you want "human readable" time (year, month, day, hour, minute) you might use an external RTC (Real Time Clock).
If you want your "system time" to be synchronised to time in the Real World, then you will also have to implement some means to set the time - search the forum for "Current Time Service" aka "CTC"
Remember that this is an embedded microcontroller system - it has no knowledge of "system time" unless you provide the code to do it.
(if you're not familiar with embedded microcontroller systems, nRF52 is probably not a good place to start)
You will probably want to use the internal RTC (Real Time Counter):
If you want "human readable" time (year, month, day, hour, minute) you might use an external RTC (Real Time Clock).
If you want your "system time" to be synchronised to time in the Real World, then you will also have to implement some means to set the time - search the forum for "Current Time Service" aka "CTC"
I agree with awneil that this is not straight forward, depending on what you intend to use it for.
If you intend to use it only for logging, there is actually a built in module. You can see how it is set up in the example found in any of the examples that doesn't use NRF_LOG_INIT(NULL). As far as I can tell, that are these:
/ble_central_and_peripheral/experimental/ble_app_att_mtu_throughput /ble_central_and_peripheral/experimental/ble_app_interactive/main.c /ble_peripheral/experimental/ble_app_cli /crypto/ifx_optiga_custom_example /peripheral/cli /peripheral/libuarte/main.c /peripheral/radio_test /peripheral/usbd_msc
I would recommend checking out the peripheral\cli example, if any of these.
Other than that, you can use the app_timer, and the function app_timer_cnt_get() to get the timestamp of the RTC (real time counter). This is not "synchronized with the world" as an RTC (Real Time Clock), as awneil said.
You would need to translate from the number of ticks to readable time, which depends on the RTC's prescaler.
Best regards,
Edvin