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

NRF calendar example error with ble_stack_init()

Hello, I am using nrf52840 board and SDK 16.0.0.

I am trying to merge this calendar example (https://github.com/NordicPlayground/nrf5-calendar-example) into ble_app_template project. My main function looks like this.

int main(void)
{   
    bool erase_bonds;
    
    /** Calendar example merging starts from here **/
    uint8_t uart_byte;
    uint32_t year, month, day, hour, minute, second;
    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART = 1;
    while(NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);
    
    nrf_cal_init();
    nrf_cal_set_callback(calendar_updated, 4);
    uart_init();
    
    /** Ble example code starts from here **/
    // Initialize.
    log_init();
    timers_init();
    buttons_leds_init(&erase_bonds);
    power_management_init();
    ble_stack_init();
    gap_params_init();

    mac_add_find();

    gatt_init();
    advertising_init();
    services_init();
    conn_params_init();
    peer_manager_init();
  

    // Start execution.
    NRF_LOG_INFO("Template example started.");
    application_timers_start();
    advertising_start(erase_bonds);
    
    /** Calendar example **/
    printf("\r\nCalendar demo\r\n\n");
    printf("s - Set time\r\n");
    printf("g - Get time\r\n");
    printf("r - Run continuous time updates\r\n\n");
    /*
    while (true)
    {
        if(app_uart_get(&uart_byte) == NRF_SUCCESS)
        {
            switch(uart_byte)
            {
                case 's':
                    run_time_updates = false;
                
                    year = (uint32_t)uart_get_parameter("Enter year", 1970, 2100);
                    month = (uint32_t)uart_get_parameter("Enter month", 0, 11);
                    day = (uint32_t)uart_get_parameter("Enter day", 1, 31);
                    hour = (uint32_t)uart_get_parameter("Enter hour", 0, 23);
                    minute = (uint32_t)uart_get_parameter("Enter minute", 0, 59);
                    second = (uint32_t)uart_get_parameter("Enter second", 0, 59);
                    
                    nrf_cal_set_time(year, month, day, hour, minute, second);
                    
                    printf("Time set: ");
                    printf("%s", nrf_cal_get_time_string(false));
                    printf("\r\n\n");
                    break;
                
                case 'g':
                    //print_current_time();
                    printf("%s", nrf_cal_get_time_string(false));
                    break;
                
               
            }
        }
    }

    */
  
    // Enter main loop.
    for (;;)
    {
        idle_state_handle();
    }
}

Here are the problems.

Problem #1

In the main function, it seems nrf_cal_init() and ble_stack_init() function are not compatible, it always resulted NRF_BREAKPOINT_COND.

static void ble_stack_init(void)
{
    ret_code_t err_code;

    err_code = nrf_sdh_enable_request();
    APP_ERROR_CHECK(err_code);  // << Where the error is happening
    ...
}

Problem #2

Also, uart_init() function from the calendar example seems to collide with log_init() function from the ble_app_template example. The error is generated when I debug this function inside the log_init(). I put the comment on the problem line.

void nrf_log_default_backends_init(void)
{
    int32_t backend_id = -1;
    (void)backend_id;
    
    ...
    
#if defined(NRF_LOG_BACKEND_UART_ENABLED) && NRF_LOG_BACKEND_UART_ENABLED
    nrf_log_backend_uart_init();        // << Where the error is happening
    backend_id = nrf_log_backend_add(&uart_log_backend, NRF_LOG_SEVERITY_DEBUG);
    ASSERT(backend_id >= 0);
    nrf_log_backend_enable(&uart_log_backend);
#endif
}

I guess the first problem might be the RTC0 issues by the SoftDevice, but the Problem 2, I don't know whats going on. I appreciate any suggestions and solutions! Thank you

Parents Reply Children
No Data
Related