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

Trying to get working RTC with BLE

I'm trying to use real time clock with BLE and softdevice. My app based on ble_app_cts_c example and calendar (https://github.com/NordicPlayground/nrf5-calendar-example)

The idea is to connect board to time service on mobile, get current date and time and init the time clock of my board.

Calendar uses RTC0, but ble uses RTC0 and I decided to use RTC1, but got the issue, that RTC1 irq is implemented in 2 different files app_timer.h and one else, also I found that the best way is to create new timer with repeated mode (i.e. every 1 sec) and use them but got also errors with RTCs

What is the best way to use date on clock in ble device not calling each time mobile service to get current data?

Parents
  • Hey IlyaM,

    RTC1 is most likely used by the app_timer library. You will need to implement the calendar timer as an app_timer, see Timer library

    You need some external source of accurate clock to update the local clock. From nrf_calendar.h:
    "

    // Sets the date and time stored in the calendar library.

    // When this function is called a second time calibration data will be automatically generated based on the error in time since the

    // last call to the set time function. To ensure good calibration this function should not be called too often

    // (depending on the accuracy of the 32 kHz clock it should be sufficient to call it between once a week and once a month).

    "

    I do not know how accurate your implementation with app_timer will be so I cannot say how often you will need to update the timer.

    Cheers,

    Håkon.

  • Hi haakonsh, thanks for your reply!

    I use the same algorithm you have mentioned above. But I'm getting a real date from my smartphone (based on ble_app_cts_c example) and it could take some time and + some ms while ios app will process my request when I send a request to get time and get the response. How to process this differences?

  • The time difference is something that you will need to measure yourself. The delays of the iOS environment is completely out of our hands. What is your real-time requirements, minutes, seconds, milliseconds, etc?

Reply Children
Related