uart_configure() error -134 using UART_CFG_PARITY

I'm trying to use parity UART communications with the nrf52840 using nRF Connect SDK v1.9.1, but I'm getting an error -134 when I call uart_configure().

When I use UART_CFG_PARITY_NONE or UART_CFG_PARITY_EVEN uart_configure() and following UART polling work great, but any other parity mode (odd, mark, space) gives me a -134 error.

Here's my code:

#define SAS_BAUD_RATE 115200
#define SAS_PARITY UART_CFG_PARITY_MARK
#define SAS_STOP_BITS UART_CFG_STOP_BITS_1
#define SAS_DATA_BITS UART_CFG_DATA_BITS_8
#define SAS_FLOW_CTRL UART_CFG_FLOW_CTRL_NONE

struct uart_config cfg;
cfg.baudrate = SAS_BAUD_RATE;
cfg.parity = SAS_PARITY;
cfg.stop_bits = SAS_STOP_BITS;
cfg.data_bits = SAS_DATA_BITS;
cfg.flow_ctrl = SAS_FLOW_CTRL;
ctrl_uart = device_get_binding(DT_LABEL(DT_NODELABEL(uart1)));
err = uart_configure(ctrl_uart, &cfg);

Is there something else I need to do to use UART with parity?

Or is UART with parity not supported for the zephyr driver? Is there a workaround to use parity UART?

Thanks!

Note: edited to add working status of UART_CFG_PARITY_EVEN

Parents
  • Hi,

    nrfx UART supports even and odd parity, not mark or space.

  • Hi ,

    Thanks for getting back to me. When I use UART_CFG_PARITY_EVEN uart_configure() returns zero (success), but when I use UART_CFG_PARITY_ODD, I get a -134 error. Do I need to change any other settings to use odd?

    Below is the relevant code. All I'm changing is the commented out line for parity.

    Thanks, Sean

    struct uart_config cfg;
    cfg.baudrate = SAS_BAUD_RATE;
    //cfg.parity = UART_CFG_PARITY_EVEN;
    cfg.parity = UART_CFG_PARITY_ODD;
    cfg.stop_bits = SAS_STOP_BITS;
    cfg.data_bits = SAS_DATA_BITS;
    cfg.flow_ctrl = SAS_FLOW_CTRL;
    
    uart_data.parity = cfg.parity;  
    
    ctrl_uart = device_get_binding(DT_LABEL(DT_NODELABEL(uart1)));
    err = uart_configure(ctrl_uart, &cfg);
    if (err != 0)
    {
        printk("cfg.parity : %u\n", cfg.parity );
        printk("ctrl_uart setup failed: %d\n", err);
    }

Reply
  • Hi ,

    Thanks for getting back to me. When I use UART_CFG_PARITY_EVEN uart_configure() returns zero (success), but when I use UART_CFG_PARITY_ODD, I get a -134 error. Do I need to change any other settings to use odd?

    Below is the relevant code. All I'm changing is the commented out line for parity.

    Thanks, Sean

    struct uart_config cfg;
    cfg.baudrate = SAS_BAUD_RATE;
    //cfg.parity = UART_CFG_PARITY_EVEN;
    cfg.parity = UART_CFG_PARITY_ODD;
    cfg.stop_bits = SAS_STOP_BITS;
    cfg.data_bits = SAS_DATA_BITS;
    cfg.flow_ctrl = SAS_FLOW_CTRL;
    
    uart_data.parity = cfg.parity;  
    
    ctrl_uart = device_get_binding(DT_LABEL(DT_NODELABEL(uart1)));
    err = uart_configure(ctrl_uart, &cfg);
    if (err != 0)
    {
        printk("cfg.parity : %u\n", cfg.parity );
        printk("ctrl_uart setup failed: %d\n", err);
    }

Children
Related