NRF 5340 resets automatically in between device scanning

hi,

                  i am trying to connect  peripherials ( blood pressure, pulseox meter) with nrf5340 using uuid and mac, initially using uuid filter are used to scan the devices around and store the mac of the device. once the mac is stored we use address filter to  filter the device based on the mac address that was stored earlier.

once the mac address matches with the stored mac address  the connect with the device is established and gatt discovery is initialed and the handles are collected and data is received and subscribing to them. everything works as expected.  and we could get the vitals from the blood pressure and pulse oximeter.

but we face an unexpected controller reset all of sudden in between in a random pattern whenever the scan_start function is initialed. since we use more than one device we initial Scan_start to initiate the filers to scan for other devices this is done during the connected, disconnected  and once gatt_ discovery call back function is succeeded. the nrf controller gets reset automatically during the scan_start function at any on the given call back function. 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
static void set_scan_filters(void)
{
// scan filters are determined based on the current mode (pairing or connecting)
// and based on which (if any) connections are currently active
int err;
// remove existing filters
//printk("Resetting scan filters\n");
bt_scan_filter_remove_all();
if(hub_mode == HUB_MODE_PAIRING_MODE)
{
// in Pairing mode, we want to just filter by UUID
printk("Setting new scan filters for pairing mode based on UUIDs and current active connections\n");
if(p_blood_pres_conn == NULL)
{
// not currently connected to any BP sensor, so add that filter
//printk("Setting scan filter for BP UUID\n");
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  

we suspected it might be due to the stack overflow and we tried to increase the size however stil the issue sustained. we are not sure what the issue is since we could not find any debug error in the debugger kindly help us how to identify the issue related to the rest.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# disable DCDC
CONFIG_BOARD_ENABLE_DCDC_APP=n
CONFIG_BOARD_ENABLE_DCDC_NET=n
CONFIG_BOARD_ENABLE_DCDC_HV=n
# Enable the UART driver
# CONFIG_UART_ASYNC_API=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_NRFX_UARTE0=y
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
# Enable the BLE stack with GATT Client configuration
CONFIG_BT=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_SMP=y
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_MAX_CONN=20
CONFIG_BT_MAX_PAIRED=20
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX