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

Use RTC1 CC[1] with ble_Conn_params.c

Hi, I have a project where, I need to change the minimum and maximum (MIN_CONN_INTERVAL and MAX_CONN_INTERVAL) connection interval to higher values like 1 second and 2 second. So, I need RTC1 CC[0] for keeping track of connection interval. But I need another RTC for led blinking and tracking other timeouts in my code. So, I used RTC CC[1] to do this purpose. The problem is, during a disconnection with the app, in ble_conn_params.c, under on_disconnect, the RTC1 is stopped (app_timer_stop). As a result of this, my periodic led blinks and timeouts for other parts of the code don't work (because the timer RTC1 is stopped). How to get around with this? I use nRF51822 AA and SDK 10.0.0 S130.THanks.

  • Just change the MIN_CONN_INTERVAL and MAX_CONN_INTERVAL in main.c, the min value you can have is 7.5 ms and the max value is 4 s.

  • Hi Sigurd, thanks for your reply. Sorry for not being clear about my question. Yes, I can change MIN_CONN_INTERVAL and MAX_CONN_INTERVAL to set the required connection interval. But I have used up Tmr 1 and 2 for other purposes. I need an RTC to control led blink frequencies. But the only RTC left is RTC1. This is used by ble_conn_param.c to negotiate the connection interval. If I change the code in app_timer.c to use RTC1->cc[1] for my purpose, (because RTC1->cc[0] is used by ble_conn_param.c for negotiating connection interval), I have a problem. The problem is when a connection between the app and nRF51 gets disconnected, the RTC1 timer is stopped in the ble_conn_param.c. But, I need RTC1 to be running forever to control my led blink frequencies. How can I achieve this?

  • Instead of using the RTC directly to blink the LED, you should instead use the app timer library in the SDK, which can be used to create multiple timer instances. Also take a look at the LED softblink library and the Application Timer Tutorial.

  • I have only one RTC left (RTC1) and it is used by ble_conn_params.c. I cant use the same RTC1 just by using app_timer library. The app_timer library uses RTC1 CC[0] (which is already used by ble_conn_params.c).

  • Hi

    I also facing a similar problem here. I merged a blink rtc freertos example with softblink example. The result was horrible with fast blink on my board + led stop blinking issue. I suspect it caused by the freertos rtc timer enter tickless idle mode.

    int main(void)
    {
        ret_code_t err_code;
        lfclk_init();
    
        // Start APP_TIMER to generate timeouts.
        err_code = app_timer_init();
        APP_ERROR_CHECK(err_code);
    
        const led_sb_init_params_t led_sb_init_param = LED_SB_INIT_DEFAULT_PARAMS(LEDS_MASK);
    
        err_code = led_softblink_init(&led_sb_init_param);
        APP_ERROR_CHECK(err_code);
    
        err_code = led_softblink_start(LEDS_MASK);
        APP_ERROR_CHECK(err_code);
    
        
        /* Activate deep sleep mode */
        SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
    
        /* Start FreeRTOS scheduler. */
        vTaskStartScheduler();
        
        while (true)
        {
            __WFE();
        }
    }
    

Related