can't seem to see Rx for either UART0 or UART2

Hello,

I'm trying to see serial data (polling async method) coming from a single-wire signal.  I have verified via an oscilloscope that there is indeed data on that wire.  However I when I plug the wire into the GPIO Rx (for both UART0 and UART2), I see nothing triggering the callback that RX is ready.  There is no flow control

Here are the specifics:

From Uart.C:

void uart_callback(const struct device *dev,
                   struct uart_event *evt,
                   void *user_data)
{
    struct device *uart = user_data;
    int err;

    switch (evt->type) {
        case UART_TX_DONE:
            //printk("Tx sent %d bytes\n", evt->data.tx.len);
            break;

        case UART_TX_ABORTED:
            printk("Error: Tx aborted\n\r");
            break;

        case UART_RX_RDY: {
            struct uart_event_rx *pRX = &evt->data.rx;
            size_t length = 0;
            size_t offset = 0;

            struct event_item event = { 0 };
            event.data = NULL;
            event.uart = uart;
            offset =  pRX->offset;
            length = pRX->len;
            printk("Received %d bytes (%s)\n\r", pRX->len, (const char *)&pRX->buf[offset]);
#if 0
            event.data = k_calloc(length, 1);
            memcpy(event.data, (char *)&pRX->buf[offset],  length - 1);
            //printk("Received data %d bytes  (%s)\n", length - 1, (char *)event.data);
            err = k_msgq_put(&event_msgq, &event, K_NO_WAIT);
            if (err) {
                /* Failed to put event into queue */
                k_free(event.data);
            }
#endif
            break;
        }
        case UART_RX_BUF_REQUEST:
        {
            uint8_t *buf;
            //printk("allocating memory\n");
            err = k_mem_slab_alloc(&uart_slab, (void **)&buf, K_NO_WAIT);
            __ASSERT(err == 0, "Failed to allocate slab");

            //printk("setting up buffer response.\n");
            err = uart_rx_buf_rsp(uart, buf, BUF_SIZE);
            __ASSERT(err == 0, "Failed to provide new buffer");
            break;
        }

        case UART_RX_BUF_RELEASED:
            //printk("Releasing memory");
            k_mem_slab_free(&uart_slab, (void **)&evt->data.rx_buf.buf);
            break;

        case UART_RX_DISABLED:
            printk("Rx Disabled.\n");
            break;

        case UART_RX_STOPPED:
            printk("Rx Stopped.\n");
            break;
    }
}

From prj.conf:

CONFIG_THREAD_MONITOR=y
CONFIG_NRF_MODEM_LIB=y                # implies CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NRF_MODEM_LIB_SYS_INIT=n       # The application will take care of initializing Modem in main.c

CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y                  # Will provide BSD name support. e.g. setsockopt() instead of nrf_setsockopt()
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_NATIVE=n                   # We are using socket offload, so set this to no

CONFIG_BUILD_WITH_TFM=y

# Memory size for k_malloc()
CONFIG_HEAP_MEM_POOL_SIZE=4096
# 4096 is the default
CONFIG_MAIN_STACK_SIZE=8192           

CONFIG_MODEM_KEY_MGMT=y               # Application wants to make calls to store keys
CONFIG_LTE_LINK_CONTROL=y             # Enable the API's to setup and configure the LTE link
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n    # The application will take care of initializing the LTE stuff in main.c

CONFIG_NEWLIB_LIBC=y                  # Use the "new" libc
CONFIG_SAMPLE_TFM_MBEDTLS=y

CONFIG_CJSON_LIB=y
CONFIG_HTTP_CLIENT=y

# MbedTLS and security
CONFIG_NORDIC_SECURITY_BACKEND=y            # Required when commenting out BUILD_WITH_TFM
CONFIG_MBEDTLS_VANILLA_BACKEND=y
CONFIG_NET_SOCKETS_SOCKOPT_TLS=y
CONFIG_NET_SOCKETS_OFFLOAD_TLS=n
CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=8192
CONFIG_MBEDTLS_HEAP_SIZE=44000
CONFIG_MBEDTLS_TLS_LIBRARY=y
CONFIG_MBEDTLS_PKCS1_V15=y
CONFIG_MBEDTLS_RSA_C=y
CONFIG_MBEDTLS=y                              # Required when commenting out CONFIG_NORDIC_SECURITY_BACKEND

CONFIG_LOG=n
CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_UART_CONSOLE=n

# Event management which handles network-related events (like ip address change, or net iface up/down for examples)
# CONFIG_NET_MGMT=y
# CONFIG_NET_MGMT_EVENT=y
# CONFIG_NET_SOCKETS_NET_MGMT=y

From the conf and overlay files:

/* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */

&uart2 {
compatible = "nordic,nrf-uarte";
	reg = < 0xa000 0x1000 >;
	interrupts = < 0xa 0x1 >;
	status = "okay";
	label = "UART_2";
	current-speed = < 0x1C200 >;
	tx-pin = < 0x00 >;
	rx-pin = < 0x01 >;
	/delete-property/ rts-pin;
	/delete-property/ cts-pin;
	/delete-property/ hw-flow-control;
};

&uart1 {
	status = "disabled";
};

// &gpiote {
//	interrupts = <13 NRF_DEFAULT_IRQ_PRIORITY>;
// };

CONFIG_TFM_SECURE_UART1=n
CONFIG_UART_ASYNC_API=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
CONFIG_NRFX_TIMER2=y
CONFIG_RESET_ON_FATAL_ERROR=n
CONFIG_TRUSTED_EXECUTION_NONSECURE=y

And for UART2 What is the GPIO config?  In one part it reads Rx is PIN 0.  In another part it reads Tx is PIN 1.

Please help.

Thanks

/Loren

Parents
  • Hi,

    Are you using a nrf9160dk or a custom board? If you are using a dk, does it work if you use other, unused pins for UART0?

    UART2 is configured as secure by default, try adding CONFIG_SPM_NRF_UARTE2_NS=y to the SPM config.

    UART2 by default has P0.23 as its rx pin, and P0.24 as its tx pin. UART1 by default has P0.0 as its rx pin, and P0.01 as its tx pin.

Reply
  • Hi,

    Are you using a nrf9160dk or a custom board? If you are using a dk, does it work if you use other, unused pins for UART0?

    UART2 is configured as secure by default, try adding CONFIG_SPM_NRF_UARTE2_NS=y to the SPM config.

    UART2 by default has P0.23 as its rx pin, and P0.24 as its tx pin. UART1 by default has P0.0 as its rx pin, and P0.01 as its tx pin.

Children
Related