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

ble_app_uart & peripheral/timer example ends in assert_nrf_callback -->app_error_handler

Hey guys,

I'm working with a Laird BL652-DVK (nrF 52832 - chip), Nordic SDK v.14.2.0 and SES (Segger Embedded Studio v.4.30). I'm working with the ble_peripheral example ble_app_uart and everything is fine and working. Now I want to use a timer event like peripheral/example "timer". This peripheral example is working separatly. But when put the timer code into ble_app_uart code I'm ending up in function "assert_nrf_callback" through followed assert in  nrf_drv_timer.c:

#ifdef SOFTDEVICE_PRESENT
    ASSERT(p_instance->p_reg != NRF_TIMER0);
#endif

timer code:

/**
 * @brief Handler for timer events.
 */
void timer_led_event_handler(nrf_timer_event_t event_type, void* p_context)
{
    switch (event_type)
    {
        case NRF_TIMER_EVENT_COMPARE0:
            nrf_gpio_pin_toggle(LED1);
            break;

        default:
            //Do nothing.
            break;
    }
}


static void timer_event_init(void)
{
    uint32_t time_ms = 200; //Time(in miliseconds) between consecutive compare events.
    uint32_t time_ticks;
    uint32_t err_code = NRF_SUCCESS;

    nrf_gpio_cfg_output(LED1);

    //Configure TIMER_SEND_DATA for generating simple light effect - leds on board will invert his state one after the other.
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    err_code = nrf_drv_timer_init(&TIMER_SEND_DATA, &timer_cfg, timer_led_event_handler);
    APP_ERROR_CHECK(err_code);

    time_ticks = nrf_drv_timer_ms_to_ticks(&TIMER_SEND_DATA, time_ms);

    nrf_drv_timer_extended_compare(
         &TIMER_SEND_DATA, NRF_TIMER_CC_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
}


int main(void)
{
    ...  //inits
    timer_event_init();
    

}

Assert nrf callback:

/**@brief Function for assert macro callback.
 *
 * @details This function will be called in case of an assert in the SoftDevice.
 *
 * @warning This handler is an example only and does not fit a final product. You need to analyse
 *          how your product is supposed to react in case of Assert.
 * @warning On assert from the SoftDevice, the system can only recover on reset.
 *
 * @param[in] line_num    Line number of the failing ASSERT call.
 * @param[in] p_file_name File name of the failing ASSERT call.
 */
void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name)
{
    app_error_handler(DEAD_BEEF, line_num, p_file_name);
}

I hope, someone can help.

Thanks in advance,

Christoph

Parents Reply Children
No Data
Related