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

Use the Real-time clock on the nRF52840 dongle with pc_ble_driver

I am trying to use the real time clock on the nRF52840 dongle using the pc-ble-driver. However, my nrf.h file has nothing in it but the following:

#ifndef NRF_H__
#define NRF_H__

/* Empty file for SDK compatibility */

#endif // NRF_H__

I assume that is the reason that none of the rtc driver methods, such as nrfx_rtc_cc_disable() are defined.

How do I access the RTC when using the pc-ble-driver library?

Parents
  • Hi,

    pc-ble-driver is only serializing the BLE related parts of the SoftDevice API. This is by design. The purpose is to allow BLE connectivity for a PC application, providing the same radio API as on an nRF application.

    Accessing the peripherals on the nRF does not make sense for pc-ble-driver, even in the few cases where the SoftDevice provides peripheral access. For any action performed by the peripherals on the nRF (other than the radio peripheral) it would make more sense to use similar peripherals / functionality directly on the PC.

    Note also that the RTC peripheral on the nRF is not a "real time clock". It is a "real time counter", and is comparable to the timer peripheral (but RTC uses the low frequency clock.)

    Regards,
    Terje

Reply
  • Hi,

    pc-ble-driver is only serializing the BLE related parts of the SoftDevice API. This is by design. The purpose is to allow BLE connectivity for a PC application, providing the same radio API as on an nRF application.

    Accessing the peripherals on the nRF does not make sense for pc-ble-driver, even in the few cases where the SoftDevice provides peripheral access. For any action performed by the peripherals on the nRF (other than the radio peripheral) it would make more sense to use similar peripherals / functionality directly on the PC.

    Note also that the RTC peripheral on the nRF is not a "real time clock". It is a "real time counter", and is comparable to the timer peripheral (but RTC uses the low frequency clock.)

    Regards,
    Terje

Children
  • I realize the rtc is just a counter. But I need to handle a situation where I must set the time on the simulated peripheral. I do not want to set the Windows OS system time, so I was thinking of using the RTC as my counter. So i some cases, using nRF functions DO make sense. Is there a Softdevice counter/clock that I could use instead? I did not find one in the APIs.

  • Hi,

    No, there is no counter API of that sort in the SoftDevice. The SoftDevice uses TIMER0 and RTC0 when enabled, but only internally. When developing for the nRF directly, part of the SoftDevice API gives access to resources shared between Application and SoftDevice through the System on Chip library, but as previously mentioned that library is not serialized.

    Again, the SoftDevice serialization is for providing the PC with radio connectivity. If you need to emulate firmware running on an nRF SoC, you must do that on the PC (and only call BLE-related SD API calls through pc-ble-driver.)

    Simulating a timestamp in the pc-ble-driver application should be no problem. Use the system clock from the PC for getting timestamps, and then store an offset from that timestamp if you want to emulate a different time setting.

    Regards,
    Terje

Related