Hello,
I am using an nRF9160dk with the nRF52840 acting as the BT controller running the Bluetooth: HCI low power UART sample (https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/hci_lpuart/README.html).
Development setup:
- nRF Connect SDK v2.3.0
- nRF9160DK, revision 1.1.0
The board scans correctly and I can connect successfully with an advertising device, however every time I reset the nRF9160DK (with the reset button) I get the following error:
[00:00:00.529,144] <wrn> lpuart: req pin low when expected high [00:00:00.529,235] <err> lpuart: Empty receiver state:4 [00:00:01.226,196] <wrn> bt_hci_core: opcode 0x0000 pool id 3 pool 0x2000cc50 != &hci_cmd_pool 0x2000cca8
I use the following code on the nRF9160:
#include <stdio.h> #include <zephyr/kernel.h> #include <zephyr/console/console.h> #include <zephyr/logging/log.h> #include <zephyr/bluetooth/bluetooth.h> #include <zephyr/bluetooth/uuid.h> #include <bluetooth/scan.h> LOG_MODULE_REGISTER(main); /** @brief Random generated UUID. **/ #define BT_UUID_RAND_VAL \ BT_UUID_128_ENCODE(0xf249bbe7, 0x4d87, 0x4322, 0xb9b2, 0x52b56dd0108e) #define BT_UUID_RAND \ BT_UUID_DECLARE_128(BT_UUID_RAND_VAL) static int start_scan(void) { int err = bt_scan_start(BT_SCAN_TYPE_SCAN_PASSIVE); if (err) { LOG_ERR("Scanning failed to start (err %d)", err); } LOG_INF("Scanning successfully started"); return err; } static void scan_filter_match(struct bt_scan_device_info *device_info, struct bt_scan_filter_match *filter_match, bool connectable) { char addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(device_info->recv_info->addr, addr, sizeof(addr)); LOG_INF("Device found: %s", addr); } static void scan_connecting_error(struct bt_scan_device_info *device_info) { LOG_WRN("Connecting failed"); } static void scan_connecting(struct bt_scan_device_info *device_info, struct bt_conn *conn) { char addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(device_info->recv_info->addr, addr, sizeof(addr)); LOG_INF("Connecting to device: %s", addr); } BT_SCAN_CB_INIT(scan_cb, scan_filter_match, NULL, scan_connecting_error, scan_connecting); static void scan_init(void) { int err; struct bt_le_scan_param scan_param = { .type = BT_LE_SCAN_TYPE_ACTIVE, .options = BT_LE_SCAN_OPT_FILTER_DUPLICATE, .interval = 0x0010, .window = 0x0010, }; struct bt_scan_init_param scan_init = { .scan_param = &scan_param, .connect_if_match = true, .conn_param = BT_LE_CONN_PARAM_DEFAULT, }; bt_scan_init(&scan_init); bt_scan_cb_register(&scan_cb); err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_UUID, BT_UUID_RAND); if (err) { LOG_ERR("Scanning filters cannot be set, err %d", err); return; } err = bt_scan_filter_enable(BT_SCAN_UUID_FILTER, false); if (err) { LOG_ERR("Filters cannot be turned on, err %d", err); return; } start_scan(); } static void ble_ready(int err) { LOG_INF("Bluetooth ready"); scan_init(); } void main() { int err; LOG_INF("Initializing Bluetooth.."); err = bt_enable(ble_ready); if (err) { LOG_ERR("Bluetooth init failed (err %d)", err); return; } }
Here is the prj.conf:
# Logging CONFIG_LOG=y CONFIG_LOG_DEFAULT_LEVEL=3 # Enable Bluetooth stack and libraries CONFIG_BT=y CONFIG_BT_H4=y CONFIG_BT_CENTRAL=y CONFIG_BT_SCAN=y CONFIG_BT_SCAN_FILTER_ENABLE=y CONFIG_BT_SCAN_UUID_CNT=1 CONFIG_UART_INTERRUPT_DRIVEN=y
nrf9160dk_nrf9160_ns.conf:
CONFIG_NRF_SW_LPUART=y CONFIG_NRF_SW_LPUART_INT_DRIVEN=y CONFIG_UART_2_ASYNC=y CONFIG_UART_2_INTERRUPT_DRIVEN=n CONFIG_UART_2_NRF_HW_ASYNC=y CONFIG_UART_2_NRF_HW_ASYNC_TIMER=2
Devicetree overlay for the nRF9160:
#include <nrf9160dk_nrf52840_reset_on_if5.dtsi> / { chosen { zephyr,bt-uart=&lpuart; }; }; &gpiote { interrupts = <49 NRF_DEFAULT_IRQ_PRIORITY>; }; &uart2 { current-speed = <1000000>; status = "okay"; /delete-property/ hw-flow-control; pinctrl-0 = <&uart2_default_alt>; pinctrl-1 = <&uart2_sleep_alt>; pinctrl-names = "default", "sleep"; lpuart: nrf-sw-lpuart { compatible = "nordic,nrf-sw-lpuart"; status = "okay"; req-pin = <21>; /* <&interface_to_nrf52840 3 0>; */ rdy-pin = <19>; /* <&interface_to_nrf52840 2 0>; */ }; }; &pinctrl { uart2_default_alt: uart2_default_alt { group1 { psels = <NRF_PSEL(UART_TX, 0, 18)>, <NRF_PSEL(UART_RX, 0, 17)>; }; }; uart2_sleep_alt: uart2_sleep_alt { group1 { psels = <NRF_PSEL(UART_TX, 0, 18)>, <NRF_PSEL(UART_RX, 0, 17)>; low-power-enable; }; }; };
Any help would be greatly appreciated.