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

RTC stops after disconnet from Android

Hi, I am using nrf51822 chip. I am using RTC to generate irq with CC. Everything works fine for IOS and old Android version. New android version makes 2 things when I disconnect:

  1. change register of CC[0] value so I changed to generate IRQ from CC[1]:

    void lfclk_config(void) { ret_code_t err_code = nrf_drv_clock_init(NULL); APP_ERROR_CHECK(err_code);

     nrf_drv_clock_lfclk_request();
    

    }

     uint32_t err_code;
    
     //Initialize RTC instance
     err_code = nrf_drv_rtc_init(&rtc, NULL, rtc_handler);
     APP_ERROR_CHECK(err_code);
    
     //Enable tick event & interrupt
     nrf_drv_rtc_tick_enable(&rtc,false);
    
     //Set compare channel to trigger interrupt after COMPARE_COUNTERTIME seconds
    
     err_code = nrf_drv_rtc_cc_set(&rtc,1,P*60*8,true);
     APP_ERROR_CHECK(err_code);
    
     //Power on RTC instance
     nrf_drv_rtc_enable(&rtc);
    
  2. stops RTC after disconnect.

I don't have any idea why on IOS works fine but on new Android it doesn't.

Thanks for help in advance.

  • I put my code under the terminal logs if you can just check it, this is eclipse project. I`m sure that RTC 1 is used just for this one task. I used NRF uart on all phones but also the application wrote by myself in xamarin, I am getting the same result. This is not the application fault beacuse this is just the disconnect event. I know that you see that CC has changed at connect, but it is not true. This logs I send by uart and this is sending when event of disconnect is done. CC is changing when I click disconnect at application on my phone and then it takes time to send infromation about disconnect.

  • Hi Marcin,

    I couldn't build your project with gcc with the Makefile provided in the \Release folder. I tried to flash the BLE_NEW.hex and BLE_S110_TEST_MM.hex and S110v8.0 on our DK but it didn't seem to advertise.

    I strongly suggest you to use any of our example in the SDK and add the RTC code to test. This way we can narrow down if the issue is related to your code or not.

  • Please try to flash BLE_NEW_mod.hex from Release folder. Also I will try today to add rtc to your example. I am using sdk 10. Which example would be the best for that test in your opinion?

  • Hi Marcin, Sorry I tried to compile your project and make.exe erased BLE_NEW_mod.hex file.

    I tried again with the file from .zip you provided, and can see the log printing out on the screen. Unfortunately, I don't have an S7 edge for testing ( I was testing with S6) and couldn't reproduce the issue.

    Please let me know your result when you test with the example we provided.

    Looking at your code I noticed that you haven't initialize the CCCD value of the UART_TX characteristic. You should handle it in BLE_GATTS_EVT_SYS_ATTR_MISSING event. Here is what we do in the uart example:

    case BLE_GATTS_EVT_SYS_ATTR_MISSING:
        // No system attributes have been stored.
        err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
        APP_ERROR_CHECK(err_code);
        break; // BLE_GATTS_EVT_SYS_ATTR_MISSING
    
  • I added now this event above and it has same behaviour, but I am changing the ble_app_uart example now, so I should have soon the result. I try to modify the ble_app_uart example, but when I add #include nrf_drv_rtc.h I am getting error that multiple definition of RTC1_IRQHandler' also when I add the #include nrf_drv_clock.h I am getting that error: make[1]: *** Brak reguł do zrobienia obiektu_build/nrf_drv_clock.o', wymaganego przez `nrf51422_xxac_s110'. Stop.

    Maybe you have an example when is used softdevice 110 where device getting IRQ by comparing CC and wake up from power_manage?

Related