This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Enabling UART 2 with hardware flow control on nRF9160DK

Hi!

I am trying to enable a UART line for a peripheral that I want to interface with on a nRF9160. I am trying to set it up as an async or interrupt driven interface as the other device may have significant delays before CTS is asserted or responses are coming in.

I am currently running nRF Connect SDK v1.9.0 on a v0.9.0 DK.

When trying to run the uart_configure or uart_callback_set function they all just return -134, which from what I have gathered is the ENOTSUP.

I have tried with both UART 1 and UART 2, UART 2 currently, but there is no change. I have also tried different pins for the UART device, but I still get the same error.

What am I doing wrong here?

My config is as follows:

DTS overlay:

/ {
    aliases {
        nc2400-aapi = &uart2;
    };

};

&uart2 {
	status = "ok";
        current-speed = <115200>;
	rx-pin = <14>;
	tx-pin = <15>;
        cts-pin = <16>;
};

&gpiote {
	interrupts = <49 NRF_DEFAULT_IRQ_PRIORITY>;
};

prj.conf

# UART
CONFIG_SERIAL=y
CONFIG_UART_LINE_CTRL=y
CONFIG_UART_USE_RUNTIME_CONFIGURE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
#CONFIG_UART_ASYNC_API=y

CONFIG_TRUSTED_EXECUTION_NONSECURE=y 
CONFIG_SPM_NRF_UARTE2_NS=y

The code I run

#define NEOCORTEC_UART_NODE DT_LABEL(DT_ALIAS(nc2400_aapi))
static const struct device *uart_handle;

static const struct uart_config uart_config = {
    .baudrate = 115200,
    .data_bits = UART_CFG_DATA_BITS_8,
    .stop_bits = UART_CFG_STOP_BITS_1,
    .flow_ctrl = UART_CFG_FLOW_CTRL_RTS_CTS,
    .parity = UART_CFG_PARITY_NONE,
};

void callback(...) {
    // just printing out the event types
    ...
}

int main() {
    int ret;
    // used to be:
    // uart_handle = device_get_binding(NEOCORTEC_UART_NODE);
    uart_handle = device_get_binding("UART_2");
    if (uart_handle == NULL) {
        LOG_ERR("Could not get UART handle");
        return -1;
    }
    
    ret = uart_configure(uart_handle, &uart_config);
    if(ret != 0) {
        LOG_ERR("Could not configure UART(err: %d)", ret);
        return -1;
    }
    
    ret = uart_callback_set(uart_handle, callback, NULL);
    if(ret != 0) {
        LOG_ERR("Could not set UART callback(err: %d)", ret);
        return -1;
    }
    
    return 0;
}

Related