Where to get "nrfx_rtc_t const *p_instance" for nrfx_rtc_init()

I could not find a way, where I can get the nrfx_rtc_t const *p_instance for the nrfx_rtc_init function. There is no example where it is shown where to get this struct from.

Parents
  • Hi,

    The nrfx_rtc_t must be defined in your application. This is normally done like this:

    #define RTC_INSTANCE_NUMBER 0
    
    const nrfx_rtc_t rtc = NRFX_RTC_INSTANCE(RTC_INSTANCE_NUMBER);

    Where RTC_INSTANCE_NUMBER represents the RTC instance you want to use (in this case RTC0).

    You can then pass this instance to nrfx_rtc_init() like this:

    nrfx_rtc_init(&rtc, .., ..);

    This is shown in the RTC peripheral example in nRF5 SDK (with nrf_drv_rtc APIs, but this is a simple replacement to nrfx).

    Best regards,
    Jørgen

  • Yes, that is correct. You need to enable the RTC instance in your sdk_config.h file (given that you are using nRF5 SDK and not nRF Connect SDK):

    // <e> NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver
    //==========================================================
    #ifndef NRFX_RTC_ENABLED
    #define NRFX_RTC_ENABLED 1
    #endif
    // <q> NRFX_RTC0_ENABLED  - Enable RTC0 instance
     
    
    #ifndef NRFX_RTC0_ENABLED
    #define NRFX_RTC0_ENABLED 1
    #endif

    Make sure that you comment out or completely remove any legacy configs for the driver in the sdk_config.h file, as these will overload the nrfx configs in the file apply_old_config.h if defined, regardless of their defined value.

    // <e> RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer
    //==========================================================
    // #ifndef RTC_ENABLED
    // #define RTC_ENABLED 1
    // #endif
    
    // <q> RTC0_ENABLED  - Enable RTC0 instance
     
    // #ifndef RTC0_ENABLED
    // #define RTC0_ENABLED 1
    // #endif

  • Ah sorry, my fault. I forgot to meantion, that I am currently using the nrf Connect SDK v 2.1.0.

Reply Children
No Data
Related