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.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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.

Fullscreen
1
2
3
4
5
6
7
8
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
...
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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