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

App_timer and RTC Calendar example confliction

I am using  timer ( created with app_timer and started with period of 1 sec ) and ported RTC calendar example in it . But both features do  not work together ( since RTC is used in both the example ) . I want to have a real time calendar which should print my current time with date -month- year and with that, periodically ,I need some timers( app timers) for sensor data acquisition and other task . So how can we achieve this ? 

exampled used : ble_app_blinky  ( ported RTC calendar and app timer )

SDK version : 15.3.0

Hardware : Nordic NRF 52 DK ( PCA10040)

  • FYI ,

    I have used RTC2 for Calendar example as ,

    #define CAL_RTC NRF_RTC2
    #define CAL_RTC_IRQn RTC2_IRQn
    #define CAL_RTC_IRQHandler RTC2_IRQHandler
    #define CAL_RTC_IRQ_Priority 3

    App_timer uses RTC1 and Softdevice used RTC0 .

    But when i run the example it goes to RTC1_IRQ_Handler and caused app_error.

  • Hello,

    So what exactly is not working? You mention that the RTC1_IRQ_Handler caused an app_error? What does the error handler say? If it only says "Fatal error." Try adding "DEBUG" to your preprocessor definitions. If you are not sure how to add preprocessor definitions, please let me know what IDE you are using. 

  • So what exactly is not working?

    refer attachment .

  • main code 

    int main(void)
    {
    // Initialize.
    log_init();
    clock_init();
    timers_init();
    system_clock_init();
    #if 0
    i2c_init();
    gpio_init();
    button_init();
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();
    advertising_start();
    #endif

    // Start execution.
    NRF_LOG_INFO("NRF_LOG_INFO is used for uart\n\n.");
    printf("Printf is used for rtt logs\n");
    NRF_LOG_INFO("Blinky example started.");


    printf("ADV sytarts .........\n");
    =============================================================

    //============================================================= calender
    #if 1
    uint8_t uart_byte;
    uint32_t year, month, day, hour, minute, second;
    //app_timer_pause();
    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);

    nrf_cal_init();
    nrf_cal_set_callback(calendar_updated, 1);

    // nrf_delay_ms(1000);
    while(1){


    print_current_time();
    //NRF_LOG_INFO("RTC Time +++++++++++++++++++++\r\n");
    NRF_LOG_FLUSH();

    //app_timer_resume();


    nrf_delay_ms(1000);
    }
    #endif
    //===================================================================== calender ends
    // Enter main loop.
    for (;;)
    {
    idle_state_handle();
    }
    }

  • system_clock_init();

    inside this i have 

    bool system_clock_init(void)
    {
    app_timer_create(&m_repeated_timer_id1,
    APP_TIMER_MODE_REPEATED,
    timer_led_event_handler);
    app_timer_start(m_repeated_timer_id1, APP_TIMER_TICKS(1000), NULL);

    return true;
    }

Related