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

Module requires 3 power cycles to initialize FDS Manager.

Hardware Description:

MKBN02A00 module based on nRF52832 SOC

Software Description 

nRF SDK 15.2.0 , SoftDevice S112

Observation:

When power_manager_init() is called before fds_manager_init(). It requires 3 power cycles to initialize FDS module. For the first 2 power cycle applications stays in wait_for_fds_ready() loop.

When power_manager_init() is called after fds_manager_init(), FDS module initializes on 1st power cycle without any problem.

Question:

What could be the possible reason for such behavior? Does power_management (sleep mode) affects the "fds module initialization" status events being generated/captured for 

fds_evt_handler. And if so why it works fine on the 3rd power cycle. Or if there is any other problem? 

Application Code:

Below is the sequence of initialization in the main function.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
// power_management_init();
ble_stack_init();
timers_init();
buttons_leds_init();
rtc_start();
fds_manager_init();
load_device_config();
power_management_init();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

fds_manager_init(void) function

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void fds_manager_init(void)
{
ret_code_t ret;
ret = fds_register(fds_evt_handler);
if (ret != FDS_SUCCESS)
{
// Registering of the FDS event handler has failed.
}
ret = fds_init();
if (ret != FDS_SUCCESS)
{
// Handle error.
}
wait_for_fds_ready();
fds_stat_t stat = {0};
ret = fds_stat(&stat);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

wait_for_fds_ready() function

Fullscreen
1
2
3
4
5
6
7
static void wait_for_fds_ready(void)
{
while (!m_fds_initialized)
{
(void) sd_app_evt_wait();
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

power_management_init() calls nrf_pwr_mgmt_int()

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
ret_code_t nrf_pwr_mgmt_init(void)
{
m_shutdown_started = false;
nrf_mtx_init(&m_sysoff_mtx);
nrf_section_iter_init(&m_handlers_iter, &pwr_mgmt_data);
PWR_MGMT_SLEEP_INIT();
PWR_MGMT_DEBUG_PINS_INIT();
PWR_MGMT_STANDBY_TIMEOUT_INIT();
PWR_MGMT_CPU_USAGE_MONITOR_INIT();
return PWR_MGMT_TIMER_CREATE();
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX