Issues in Modifying an nRF52840-based Peripheral UART Program to Host_Only

I wanted to change the Peripheral UART program in the nrf samples to the host_only version, and I made some attempts. I added the following code to the prj.conf file:

CONFIG_BT_HCI=y
CONFIG_BT_CTLR=n
CONFIG_BT_H4=y

In the app.overlay file I added the following code:

/ {
	chosen {
		nordic,nus-uart = &uart0;
	};
};

&uart0 {
	current-speed = <115200>;
	// hw-flow-control;
};
&uart1 {
    compatible = "nordic,nrf-uarte";
    status = "okay";
    current-speed = <115200>;
    pinctrl-0 = <&uart1_default>;
    pinctrl-1 = <&uart1_sleep>;
    pinctrl-names = "default", "sleep";
};
/ {
    chosen {
        // zephyr,console = &uart0;
        // zephyr,shell-uart = &uart0;
        zephyr,bt-uart = &uart0;
        zephyr,bt-c2h-uart = &uart0;
    };
 };

After build and flash, the program doesn't seem to run correctly. After debug, I find that the program enters an endless loop in the uart_init() function, specifically "err = uart_callback_set(uart, uart_cb, NULL);" this line produced an error.

Parents
  • Hi, 

    Please let me know if you managed to make the beacon sample worked as the host when you connect to the controller  ?
    When you use the peripheral uart there can be a conflict as the sample uses UART to receive command (from human user) and the UART you are using for HCI communication. 
    In your case you are using uart0 for both normal nus-uart and HCI UART. You should choose for example nus-uart to use UART0 and HCI uart to use UART 1. 

  • I'm terribly sorry. I forgot to reply. With your help, I have successfully made the beacon sample worked as the host.
    I enabled uart1 in the overlay file with the intention of using UART 1 as HCI uart. When the overlay file is configured with the following code:

    &uart0 {
    	current-speed = <115200>;
    	// hw-flow-control;
    };
    &uart1 {
        compatible = "nordic,nrf-uarte";
        status = "okay";
        current-speed = <115200>;
        pinctrl-0 = <&uart1_default>;
        pinctrl-1 = <&uart1_sleep>;
        pinctrl-names = "default", "sleep";
    };
    / {
        chosen {
            nordic,nus-uart = &uart0;
            // zephyr,console = &uart0;
            // zephyr,shell-uart = &uart0;
            zephyr,bt-uart = &uart1;
            zephyr,bt-c2h-uart = &uart1;
        };
     };
    

    the program has the same problem. I don't know what the problem is with this project.

    Looking forward to your reply. 

  • Hi, 
    Please try to check the log (RTT log or UART log). 
    Have you made sure you connect the controller board to the right UART pins ? I used P0.28, P0.29, P0.30, P0.31 for the UART connection. 
    The 4 lights turn off most likely because it's no longer assert with uart_init but it can't communicate with the BLE controller board. 

  • I have verified that my pins are connected correctly. I conducted tests using the same configuration file and overlay file as you did, with no other changes made. When using the serial assistant on PC to capture the TX pin of uart1, I found no output information. My suspicion is that bt_enable() is not being executed effectively. Do you utilize the aforementioned files in the peripheral_uart routine to enable communication between host and controller? Have there been any additional modifications to either the host or controller?

    In any case, my objective is to troubleshoot why debugging isn't functioning so that I can identify and address the issue.

  • Hi, 
    hw-flow-control; on uart0 could be the problem there. 
    Please try the attached projects. I compiled them using SDK v2.6.0. I tested using 2 nRF52840DKs. 
    The compiled hex files is also provided in each project. 

    hci_uart.zip

    peripheral_uart_hci.zip

  • Hi,

    Thank you very much. The program is functioning properly. However, during the testing of the beacon, I did not activate hw-flow-control and the program still operated normally. I would like to understand in detail when hw-flow-control is necessary.

  • Hi,

    The reason is that the beacon sample doesn't use UART for communicate with end user (receive and send data from UART to BLE).

    The code for UART in peripheral_uart doesn't support hw flow control as far as I know. 

Reply Children
No Data
Related