BLE central_uart cannot work with nRF21540 EK

I have two nRF52833 development boards: one is connected to the nRF21540 EK as TX (using BLE peripheral_uart), and the other is used as RX (BLE central_uart). My issue is that, with the TX setup being completely identical, when I use ble_app_uart_c from the nRF5 SDK, it correctly receives the signal and prints the RSSI (as shown in Figure 1). However, when I use central_uart from NCS, an error occurs (as shown in Figure 2). If I comment out the following configurations:

CONFIG_MPSL_FEM=y
CONFIG_MPSL=y
CONFIG_MPSL_FEM_NRF21540_GPIO=y
CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y
CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB=20
CONFIG_MPSL_FEM_NRF21540_RX_GAIN_DB=13

it works correctly and displays the results, as shown in Figure 3.

What is happening here. I am looking forwart to hearing from you :)
Parents
  • Hi,

    I have some questions to better understand this and attempt to reproduce:

    1. this issue depends on the firwmare runnign on the central, and that the central_uart build for the nRF52833 DK with nRF21540 shield is needed to trigger this. Is it correct?
    2. Can you show exactly how you build the central project so that I can replicate the configuration on my end?
    3. Which nRF Connect SDK version are you using?
    4. Which SDK version are you using on the peripheral side? (and if you have tested others, does it matter?)
  • Thank you for your reply!

    1. The issue depends on the firmware running on the peripheral and central. If I delete the FEM config for the peripheral or I change the central from NCS to nRF5 SDK firmware this issue will not happen.

    2. For NCS, I have build the central project like this

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    # Enable the UART driver
    CONFIG_UART_ASYNC_API=y
    CONFIG_NRFX_UARTE0=y
    CONFIG_SERIAL=y
    CONFIG_GPIO=y
    # Make sure printk is printing to the UART console
    CONFIG_CONSOLE=y
    CONFIG_UART_CONSOLE=y
    CONFIG_HEAP_MEM_POOL_SIZE=2048
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    3 and 4. I have tried 2.8 and 2.9 for both peripheral and central ang both of them have this issue. And most of the time the central can have the connedtion and then give me these errors. For 10% time it can receive the data and print out RSSI.

    My central code shows below:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    * Copyright (c) 2018 Nordic Semiconductor ASA
    *
    * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    */
    /** @file
    * @brief Nordic UART Service Client sample
    */
    #include <errno.h>
    #include <zephyr/kernel.h>
    #include <zephyr/device.h>
    #include <zephyr/devicetree.h>
    #include <zephyr/sys/byteorder.h>
    #include <zephyr/sys/printk.h>
    #include <zephyr/bluetooth/bluetooth.h>
    #include <zephyr/bluetooth/hci.h>
    #include <zephyr/bluetooth/conn.h>
    #include <zephyr/bluetooth/uuid.h>
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Thank you so much for your time and patience!

  • Thank you so much for your reply! Below are my projects:

    Central code:

    config

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    # Enable the UART driver
    CONFIG_UART_ASYNC_API=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
    # Enable the BLE modules from NCS
    CONFIG_BT_NUS_CLIENT=y
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    main.c

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    * Copyright (c) 2018 Nordic Semiconductor ASA
    *
    * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    */
    /** @file
    * @brief Nordic UART Service Client sample
    */
    #include <errno.h>
    #include <zephyr/kernel.h>
    #include <zephyr/device.h>
    #include <zephyr/devicetree.h>
    #include <zephyr/sys/byteorder.h>
    #include <zephyr/sys/printk.h>
    #include <zephyr/bluetooth/bluetooth.h>
    #include <zephyr/bluetooth/hci.h>
    #include <zephyr/bluetooth/conn.h>
    #include <zephyr/bluetooth/uuid.h>
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Peripheral:

    config:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    # Enable the UART driver
    CONFIG_UART_ASYNC_API=y
    CONFIG_NRFX_UARTE0=y
    CONFIG_SERIAL=y
    CONFIG_GPIO=y
    # Make sure printk is printing to the UART console
    CONFIG_CONSOLE=y
    CONFIG_UART_CONSOLE=y
    CONFIG_HEAP_MEM_POOL_SIZE=2048
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    main.c

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    * Copyright (c) 2018 Nordic Semiconductor ASA
    *
    * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    */
    /** @file
    * @brief Nordic UART Bridge Service (NUS) sample
    */
    #include <uart_async_adapter.h>
    #include <zephyr/types.h>
    #include <zephyr/kernel.h>
    #include <zephyr/drivers/uart.h>
    #include <zephyr/usb/usb_device.h>
    #include <zephyr/device.h>
    #include <zephyr/devicetree.h>
    #include <soc.h>
    #include <zephyr/bluetooth/bluetooth.h>
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I have only change then main.c for central and peripheral devices, other code is the same with samples:) I don't have a sniffer. Thank you so much for your patience!

  • Hi,
    I tested your code in SDK 2.9 (only needed to add #include <dk_buttons_and_leds.h> in the peripheral main.c as it had been removed for some reason while still beeing needed). And I am not able to reproduce the described behaviour, I still see things working consistently when havin the FEM module enabled by uncommenting the part in prj.conf and mounting a nRF21540 EK on a nRF52833 DK.
     
    However, I see the same as your in your second (failing) terminal output when I reset the peripheral, and this is regardless of if the FEM is enabled or not on the peirpheral side. Specifically, this seems to be caused by the central implementation not handlign re-connection properly, though I have not got to the bottom of that. Can you confirm if this is the case also in your testing?
  • Thank you for your reply! Yes, I encountered the problems on the central divice and have no clue about that. As there is no issue if I use the NRF5 SDK.

  • Today I noticed if the central device cannot connect, every time I press reset button it start to work well. What happen for this situation. Is there any issue in my code? Could you please help me find out the problems?Grinning

  • Hi,

    I have not been able to test now, but I see a few things worth checking out. In your init_rssi_monitoring() function which you call every time a new connection is made, you also call k_work_init_delayable(). This should be OK, but only when nothign is scheduled, so dependign on priorities and timing, this could potentially cause problems. So I would take the k_work_init_delayable() call out so that you only call it once.

    Also, I wonder if there is an issue with the work queue? I suggest checking the return value from k_work_schedule() to verify that it succeeds. And if it does not, what is the error code? Other than that, it makes sense to debug to see if somethign that should have happened does not, and track that down with the debugger to see why.

Reply
  • Hi,

    I have not been able to test now, but I see a few things worth checking out. In your init_rssi_monitoring() function which you call every time a new connection is made, you also call k_work_init_delayable(). This should be OK, but only when nothign is scheduled, so dependign on priorities and timing, this could potentially cause problems. So I would take the k_work_init_delayable() call out so that you only call it once.

    Also, I wonder if there is an issue with the work queue? I suggest checking the return value from k_work_schedule() to verify that it succeeds. And if it does not, what is the error code? Other than that, it makes sense to debug to see if somethign that should have happened does not, and track that down with the debugger to see why.

Children
  • Hi

    Today I have modify my code, and I think the problem is nor about the schedule, as now I will have "bt_hci_core: opcode 0x1405 status 0x02" after reconnection.

    main.c

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    * Copyright (c) 2018 Nordic Semiconductor ASA
    *
    * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    */
    /** @file
    * @brief Nordic UART Service Client sample
    */
    #include <errno.h>
    #include <zephyr/kernel.h>
    #include <zephyr/device.h>
    #include <zephyr/devicetree.h>
    #include <zephyr/sys/byteorder.h>
    #include <zephyr/sys/printk.h>
    #include <zephyr/bluetooth/bluetooth.h>
    #include <zephyr/bluetooth/hci.h>
    #include <zephyr/bluetooth/conn.h>
    #include <zephyr/bluetooth/uuid.h>
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    proj.config

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    # Enable the UART driver
    CONFIG_UART_ASYNC_API=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
    # Enable the BLE modules from NCS
    CONFIG_BT_NUS_CLIENT=y
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I have tried CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y and CONFIG_BT_HCI_VS_EXT=y. As this ticket has similar issue https://devzone.nordicsemi.com/f/nordic-q-a/91339/error-with-bluetooth-hci-function-bt_hci_cmd_send_sync

    I hope you can help me figure it out

  • Hi,

    I am sorry for the delay. I am looking into this but have not got to the bottom of this yet (though this seems similar to what was dicussed in this thread). I suggest we continue in your new thread.