Trying to Implement central_uart on a nrf52840 dongle

Hello! I am a newcomer to nrf and embedded programming (other than basic arduino and micropython projects). So far I have gone through many of the devacademy walkthroughs. What I want to do is simply implement central_uart and peripheral_uart on two nrf52840 dongles so I can use NUS to send messages back and forth between them. I already have my peripheral send messages to my phone's nrf connect app and this works well, however it is very basic (I wrote it myself with peripheral_nus example) so I want to transition to peripheral_uart. My first step was to get central_uart and/or peripheral_uart working on my dongles. I started with central_uart. However, when flashing it onto my device and looking at the log through the serial port I run into "<err> central_uart: uart_init failed (err -88). After adding some debugging messages into the uart_init function I find that the -88 error is coming from the "uart_callback_set" command. I am not sure how to remedy this, or if additional work needs to be done from the stock central_uart before I flash it onto my nrf 52840 dongle.

Other than debug messages and enabling them I have not edited the code from the stock.

Thoughts? Advice?

Parents
  • Hello,

    I couldn't find an issue with the callback. Could you include the following configurations in the application and see if it works? Let me know if it does. If not, inform me and I will test the central_uart sample for the dongle.

    # Dongle -route UART to USB CDC ACM
    CONFIG_USB_DEVICE_STACK=y
    CONFIG_USB_DEVICE_PRODUCT="nRF52840 Dongle"
    CONFIG_USB_CDC_ACM=y

    Kind regards,

    Abhijith

Reply
  • Hello,

    I couldn't find an issue with the callback. Could you include the following configurations in the application and see if it works? Let me know if it does. If not, inform me and I will test the central_uart sample for the dongle.

    # Dongle -route UART to USB CDC ACM
    CONFIG_USB_DEVICE_STACK=y
    CONFIG_USB_DEVICE_PRODUCT="nRF52840 Dongle"
    CONFIG_USB_CDC_ACM=y

    Kind regards,

    Abhijith

Children
  • Abjijith,

    thank you for your efforts in this! Unfortunately, that still did not work :(. Now i am getting a slightly different error message (the following).

    *** Booting nRF Connect SDK 3758bcbfa5cd ***
    [00:00:00.008,117] <inf> fs_nvs: 4 Sectors of 4096 bytes
    [00:00:00.008,117] <inf> fs_nvs: alloc wra: 0, fb0
    [00:00:00.008,148] <inf> fs_nvs: data wra: 0, 5c
    [00:00:00.008,331] <inf> bt_sdc_hci_driver: SoftDevice Controller build revision: 
                                                36 f0 e5 0e 87 68 48 fb  02 fd 9f 82 cc 32 e5 7b |6....hH. .....2.{
                                                91 b1 5c ed                                      |..\.             
    [00:00:00.011,749] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    [00:00:00.011,779] <inf> bt_hci_core: HW Variant: nRF52x (0x0002)
    [00:00:00.011,810] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 54.58864 Build 1214809870
    [00:00:00.012,420] <inf> bt_hci_core: No ID address. App must call settings_load()
    [00:00:00.012,420] <inf> central_uart: Bluetooth initialized
    [00:00:00.012,634] <err> settings: set-value failure. key: bt/name error(-2)
    [00:00:00.013,244] <inf> bt_hci_core: Identity: C8:F8:6C:27:EB:10 (random)
    [00:00:00.013,275] <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x118f, manufacturer 0x0059
    [00:00:00.013,305] <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x118f
    [00:00:00.014,465] <inf> central_uart: Settings Loaded
    [00:00:00.014,465] <dbg> central_uart: uart_init: Initializing UART
    [00:00:00.014,495] <dbg> central_uart: uart_init: UART device is ready
    [00:00:00.014,526] <dbg> central_uart: uart_init: rx len is 0
    [00:00:00.014,526] <dbg> central_uart: uart_init: Setting uart_callback
    [00:00:00.014,556] <dbg> central_uart: uart_init: was callback set?: -88
    [00:00:00.014,556] <err> central_uart: uart_init failed (err -88)
    

    Particularly: <err> settings: set-value failure. key: bt/name error(-2)

    And then the usual error: <err> central_uart: uart_init failed (err -88)

  • If nothing is driving the uart input pin there will be a framing error and empty buffer on initialisation; if something is driving the rx pin before power on there will be problems with correct reset behaviour unless the driving device powers up with VDD.

    Suggested fix simply enable the Rx pin pull-up:

    		group1 {
    			psels = <NRF_PSEL(UART_TX, 1, 2)>,
    					<NRF_PSEL(UART_RX, 1, 1)>;
    			bias-pull-up;
    		};
    

    /nordic,nrf-pinctrl

    Edit: suggest also adding high drive for tx:

    		group1 {
    			psels = <NRF_PSEL(UART_RX, 1, 1)>;
    			bias-pull-up;
    		};
    		group2 {
    			psels = <NRF_PSEL(UART_TX, 1, 2)>;
    		    nordic,drive-mode = <NRF_DRIVE_H0H1>;
    		};

Related