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

nrf_drv_rtc_tick_enable crash app when using DFU secure bootloader (with buttonless dfu App)

Hello everybody,

I am currently developing on NRF52DK (2018.37) waiting for my proto to be manufactured.

I am using SDK v15.2 with gnu/gcc toolchain under Linux Ubuntu 18.04.

Every project I use is from examples/paht/to/example/pca10040e to easily port project when I'll receive my proto with nRF52810

This example SDK_ROOT/examples/peripheral/rtc perfectly runs and when i try to port it with secure_bootloader and ble_app_buttonless_dfu it first fails when trying enable the lfclock with NRF_ERROR_MODULE_ALREADY_INITIALIZED. I believe the LF clk is initialized by the soft_device or the bootloader ?

I have already seen this post but the answer didn't help me much.

When i don't call lfclk_config I detected that a problem occured when nrf_drv_rtc_tick_enable is called but I have no Log message on the UART. (Even first ones)

This is my main :

int main(void)
{
	bool erase_bonds;
	ret_code_t err_code;

	log_init();
	NRF_LOG_INFO("App begin init");
	// Initialize the async SVCI interface to bootloader before any interrupts are enabled.
	err_code = ble_dfu_buttonless_async_svci_init();
	APP_ERROR_CHECK(err_code);

	timers_init();
	power_management_init();
	buttons_leds_init(&erase_bonds);
	ble_stack_init();
	peer_manager_init();
	gap_params_init();
	gatt_init();
	db_discovery_init();
	services_init();
	advertising_init();
	sensor_simulator_init();
	conn_params_init();
	NRF_LOG_INFO("App RTC config");
	lfclk_config();
	rtc_config();
	NRF_LOG_INFO("Souriau App with OTA DFU started.");

	// Start execution.
	application_timers_start();
	advertising_start(erase_bonds);

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

/** @brief Function starting the internal LFCLK XTAL oscillator.
 */
void lfclk_config(void)
{
    ret_code_t err_code = nrf_drv_clock_init();
    APP_ERROR_CHECK(err_code);

    nrf_drv_clock_lfclk_request(NULL);
}

/** @brief Function initialization and configuration of RTC driver instance.
 */
void rtc_config(void)
{
    uint32_t err_code;

    //Initialize RTC instance
    nrf_drv_rtc_config_t config = NRF_DRV_RTC_DEFAULT_CONFIG;
    config.prescaler = 4095;
    err_code = nrf_drv_rtc_init(&rtc, &config, rtc_handler);
    APP_ERROR_CHECK(err_code);

    //Enable tick event & interrupt
    nrf_drv_rtc_tick_enable(&rtc,true);

    //Set compare channel to trigger interrupt after COMPARE_COUNTERTIME seconds
    err_code = nrf_drv_rtc_cc_set(&rtc,0,COMPARE_COUNTERTIME * 8,true);
    APP_ERROR_CHECK(err_code);

    //Power on RTC instance
    nrf_drv_rtc_enable(&rtc);
}

I don't have any log message to give considering that I don't have any on my screen.

If I comment nrf_drv_rtc_tick_enable and nrf_drv_rtc_enable then I have all my regular messages and everything is working, except the RTC of course.

Do you know what can I do / modify to port RTC on my example ?

Thanks,

Clément

Related