UART communication between nrf9160 and nrf52840

I am have programmed serial_lte_modem (ncs 2.1.0) to nrf9160DK with following configuration:

CONFIG_SLM_CONNECT_UART_2=y
CONFIG_UART_2_NRF_HW_ASYNC_TIMER=2
CONFIG_UART_2_NRF_HW_ASYNC=y
CONFIG_SLM_WAKEUP_PIN=31
CONFIG_SLM_INDICATE_PIN=30

and overlay file:

&uart0 {
	status = "okay";
};

&uart2 {
	compatible = "nordic,nrf-uarte";
	current-speed = <115200>;
	status = "okay";
	hw-flow-control;

	pinctrl-0 = <&uart2_default_alt>;
	pinctrl-1 = <&uart2_sleep_alt>;
	pinctrl-names = "default", "sleep";
};

&i2c2 {
	status = "disabled";
};

&pinctrl {
	uart2_default_alt: uart2_default_alt {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 10)>,
				<NRF_PSEL(UART_RX, 0, 11)>,
				<NRF_PSEL(UART_RTS, 0, 12)>,
				<NRF_PSEL(UART_CTS, 0, 13)>;
		};
	};

	uart2_sleep_alt: uart2_sleep_alt {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 10)>,
				<NRF_PSEL(UART_RX, 0, 11)>,
				<NRF_PSEL(UART_RTS, 0, 12)>,
				<NRF_PSEL(UART_CTS, 0, 13)>;
			low-power-enable;
		};
	};
};

Then I have connected my external nrf52840 p0.19 to nrf9160DK p0.10 and nrf52840 p0.20 to nrf9160DK p0.11.

Initialize UART on nrf52840:

void uart_init(void)
{
    uint32_t err_code;
    app_uart_comm_params_t const comm_params =
        {
            .rx_pin_no = 19,
            .tx_pin_no = 20,
            .rts_pin_no = NRF_UART_PSEL_DISCONNECTED,
            .cts_pin_no = NRF_UART_PSEL_DISCONNECTED,
            .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
            .use_parity = false,
            .baud_rate = NRF_UART_BAUDRATE_115200

        };
    APP_UART_FIFO_INIT(&comm_params,
        UART_RX_BUF_SIZE,
        UART_TX_BUF_SIZE,
        uart_event_handle,
        APP_IRQ_PRIORITY_LOWEST,
        err_code);
    APP_ERROR_CHECK(err_code);
}

And send AT command:

int8_t send_at_command(char *at_command)
{
    NRF_LOG_INFO("%s", at_command);
    for (int i = 0; i < strlen(at_command); i++)
    {
        uint32_t retval = app_uart_put(at_command[i]);
        if (retval != 0)
        {
            app_uart_flush();
            return -1;
        }
    }
    app_uart_put('\r');
    app_uart_put('\n');
    return 0;
}

After sending the AT command uart_event_handler interrupts with APP_UART_TX_EMPTY

Is there something wrong with my configuration? Any help is much appreciated.

Parents
  • Hi,

    APP_UART_TX_EMPTY just means that the transmission has finished, so there isn't a problem.
    You can use this event to start another transmission if for instance you saved another message inside a fifo.

    Are you really using flow control?
    According to your nrf9160 overlay file you are using it, but when initialising the uart on the nrf52840 you are disabling it.

    Kind regards,
    Johannes

  • Transmission finishes, but I get no response from nrf9160, I.e. no APP_UART_DATA_READY or APP_UART_DATA events or any response to AT commands. Not using flow control, disabled it from the nrf9160 side as well.

  • Hi,

    if you don't want to use it you have to remove the "hw-flow-control" from your overlay file.
    Could you post your whole prj.conf?

    Kind regards,
    Johannes

  • Hi,

    I did remove it. Here is the prj.conf code:

    #
    # Copyright (c) 2020 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    # General config
    CONFIG_LOG=y
    CONFIG_LOG_DEFAULT_LEVEL=3
    CONFIG_STACK_SENTINEL=y
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    CONFIG_RING_BUFFER=y
    
    # Segger RTT
    CONFIG_USE_SEGGER_RTT=n
    CONFIG_RTT_CONSOLE=n
    CONFIG_UART_CONSOLE=y
    CONFIG_LOG_BACKEND_RTT=n
    CONFIG_LOG_BACKEND_UART=y
    
    # Network
    CONFIG_NETWORKING=y
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_NATIVE=n
    
    # Modem library
    CONFIG_NRF_MODEM_LIB=y
    # Align the max FD entry to NRF_MODEM_MAX_SOCKET_COUNT(8)
    CONFIG_POSIX_MAX_FDS=8
    # Enable below for modem trace
    #CONFIG_NRF_MODEM_LIB_TRACE=y
    # Handle modem fault
    CONFIG_NRF_MODEM_LIB_ON_FAULT_APPLICATION_SPECIFIC=y
    
    # Use GPIO
    CONFIG_GPIO=y
    CONFIG_GPIO_NRFX=y
    
    # UART interface
    CONFIG_SERIAL=y
    CONFIG_UART_ASYNC_API=y
    CONFIG_NRFX_TIMER2=y
    
    # Stacks and heaps
    CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_HEAP_MEM_POOL_SIZE=16384
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
    
    # Device power management
    CONFIG_PM_DEVICE=y
    
    # FOTA
    CONFIG_HTTP_PARSER_URL=y
    CONFIG_FOTA_DOWNLOAD=y
    CONFIG_FOTA_DOWNLOAD_PROGRESS_EVT=y
    CONFIG_DFU_TARGET=y
    CONFIG_DOWNLOAD_CLIENT=y
    CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_IMG_MANAGER=y
    
    # FLASH
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    CONFIG_IMG_ERASE_PROGRESSIVELY=y
    
    # Settings
    CONFIG_SETTINGS=y
    CONFIG_SETTINGS_FCB=y
    CONFIG_FCB=y
    
    # nRF Cloud
    #CONFIG_NRF_CLOUD_IPV6=y
    CONFIG_NRF_CLOUD_MQTT=y
    CONFIG_NRF_CLOUD_FOTA=n
    CONFIG_NRF_CLOUD_AGPS=y
    CONFIG_NRF_CLOUD_AGPS_FILTERED=n
    CONFIG_NRF_CLOUD_PGPS=y
    CONFIG_NRF_CLOUD_CELL_POS=y
    CONFIG_NRF_CLOUD_LOG_LEVEL_INF=y
    CONFIG_NRF_CLOUD_GPS_LOG_LEVEL_INF=y
    CONFIG_DATE_TIME=y
    CONFIG_MODEM_INFO=y
    CONFIG_MODEM_INFO_ADD_DATE_TIME=n
    CONFIG_AT_MONITOR=y
    CONFIG_MODEM_JWT=y
    CONFIG_NRF_CLOUD_CLIENT_ID_SRC_INTERNAL_UUID=y
    
    #
    # SLM-specific configurations
    #
    CONFIG_SLM_CUSTOMIZED=n
    CONFIG_SLM_LOG_LEVEL_INF=y
    CONFIG_SLM_EXTERNAL_XTAL=n
    CONFIG_SLM_START_SLEEP=n
    
    # nRF Cloud based location services
    CONFIG_SLM_AGPS=n
    CONFIG_SLM_PGPS=n
    CONFIG_SLM_CELL_POS=n
    
    # Serial DFU support
    CONFIG_SLM_NRF52_DFU=n
    CONFIG_SLM_NRF52_DFU_LEGACY=n
    

  • Hello, 

    Please make sure that the nRF9160 Board Controller has not enabled external memory control.

    Kind regards,
    Øyvind

Reply Children
Related