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

How to add clock function to ble_app_uart? (SDK12 with nRF51DK)

I need to add a clock function to the ble_app_uart example (SDK12). Where can I find a hint on how to do it? Do I need an external 32768Hz quartz? I wanted to derive from the 16 MHz quartz instead to save cost.

Parents
  • To make it a bit more clear, I am using the ble_app_uart example from SDK12 to start building my application. According to what I read, RTC0 and RTC1 are already used and nRF51DK doesn't have RTC2. This means I have to implement my watch (clock and date) on a Timer. Is this right?

  • Sergio T said:
    I wanted to use the synthesized clock so I think all I need to do is set the source to NRF_CLOCK_SRC_SYNTH.

     Yes. You can do this, but be aware that this draws a bit more current, but it is also more accurate than the RC oscillator.

    Sergio T said:
    The next question is where can I find information about the clock function? I need to know how I can count the time and date, including daylight saving and so on.

     Well. We don't have a library for this. The app_timer is probably the way you want to go here. You can absolutely base your application on the ble_app_uart example. Just look at e.g. the ble_app_hrs example on how to set up the app_timer for your application. This example uses it to update the simulated battery level.

    I believe that to keep track of time, you would need a timer that times out every second, 10 seconds, minute, hour, or whatever time resolution you need. Then use this timer to increment your "current time" variable. 

    To get the current time, you can look into the "current time service" which is used in the ble_app_cts_c example (description here). This service will give you the current time from the device that is connected, e.g. a phone, in order to synchronize the current time and date.

    EDIT:

    The link to the description of the ble_app_cts_c example as nRF51 is not supported in SDK15. Use this link instead:

    https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v12-3-0/ble_sdk_app_cts_c

    Best regards,

    Edvin

Reply
  • Sergio T said:
    I wanted to use the synthesized clock so I think all I need to do is set the source to NRF_CLOCK_SRC_SYNTH.

     Yes. You can do this, but be aware that this draws a bit more current, but it is also more accurate than the RC oscillator.

    Sergio T said:
    The next question is where can I find information about the clock function? I need to know how I can count the time and date, including daylight saving and so on.

     Well. We don't have a library for this. The app_timer is probably the way you want to go here. You can absolutely base your application on the ble_app_uart example. Just look at e.g. the ble_app_hrs example on how to set up the app_timer for your application. This example uses it to update the simulated battery level.

    I believe that to keep track of time, you would need a timer that times out every second, 10 seconds, minute, hour, or whatever time resolution you need. Then use this timer to increment your "current time" variable. 

    To get the current time, you can look into the "current time service" which is used in the ble_app_cts_c example (description here). This service will give you the current time from the device that is connected, e.g. a phone, in order to synchronize the current time and date.

    EDIT:

    The link to the description of the ble_app_cts_c example as nRF51 is not supported in SDK15. Use this link instead:

    https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v12-3-0/ble_sdk_app_cts_c

    Best regards,

    Edvin

Children
Related