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

Porting of RTC example code to ble_app_bliky

Hello,

 

I am using nRF52832, SDK_15.3.0, S132 SoftDevice and Segger for flash the image. I am using ‘ble_app_blinky’.

I am porting RTC example code as is into ble_app_blinky. I have below queries.

 

1) When I use RTC0, code got crashed with below error on Terminal.

              const nrf_drv_rtc_t rtc = NRF_DRV_RTC_INSTANCE(0);

 

              <error> app: SOFTDEVICE: INVALID MEMORY ACCESS

 

              In SoftDevice manual its mentioned as RTC0 is blocked by SoftDevice. But as part of app_timer_init() I am seeing RTC1 being used. Whereas in document it is mentioned RTC1 as open. Whether both RTC0 & RTC1 are being used by SoftDevice.

 

Later I changed to RTC2 and it worked as expected.

const nrf_drv_rtc_t rtc = NRF_DRV_RTC_INSTANCE(2);

 

2) Even though SoftDevice uses RTC0, how will I come to know which CC[0..3] is used by RTC0, so that I can give other CC as part of RTC2 configuration.

3) Since I am using RTC2, in-between LED blink (Say 250ms) whether chip will go to low power mode ? Is it taken care automatically (By calling idle_state_handle()) or do need to add any extra code ?

             

4) In TIMER once timer is enabled COUNTER will keep on triggering, whereas in RTC its only once. After that there is not COUNTER interrupt in RTC. For this , in rtc_handler() do I need to clear COUNTER register and write CC once again. If I comment nrf_drv_rtc_cc_set() I am not seeing rtc_handler() event handler getting triggered.

 

              if (int_type == NRF_DRV_RTC_INT_COMPARE0) // For RTC2, CC0 is used

              {

        nrf_gpio_pin_toggle(LED_1);

        nrf_drv_rtc_counter_clear(&rtc);

        nrf_drv_rtc_cc_set(&rtc, 0, 32UL, true); // With 255 prescale (250ms)  // Is this really required ??

 

    Why is that in RTC whereas not in TIMER functionality and how to trigger rtc_handler() continuously.

Thanks & Regards

Vishnu Beema

Related