[nRF Connect SDK] uart tx failure

Target nRF52832(nrf52dk_nrf52832)
SDK NCS v1.9.1

my.dts
&uart0 {
status = "okay";
tx-pin = <14>;
rx-pin = <13>;
rts-pin = <17>;
cts-pin = <16>;
current-speed = <921600>;
hw-flow-control;
};

[URGENT]
Issue: UART Tx failure. (Most of time. In failure case, any data did not transmitted, I checked Tx pin with microscope)
UART works well with PC(usb to serial) Tx, Rx
Issue happened  with my target MCU's uart.(UART Rx is good, Tx failed)
But It was fine with old SDK(nRF5_SDK_17.1.0_ddde560).(Tx, Rx). NCS has issue.

Prj.conf
# Enable the UART driver
CONFIG_UART_CONSOLE=n
CONFIG_UART_ASYNC_API=n
CONFIG_UART_INTERRUPT_DRIVEN=y

[main.c]
static void uart_init_irq(void)
{
    lpuart = device_get_binding("UART_0");
    uart_irq_callback_set(lpuart, uart_irq_handler);
}

static void uart_irq_handler(const struct device *dev, void *context)
{
	uint8_t *data_tx = NULL;

	uart_irq_update(dev);
	if (uart_irq_tx_ready(dev)) {
		int nr_bytes_read =
			ring_buf_get_claim(&uart_rb, &data_tx, CONFIG_UART_0_NRF_TX_BUFFER_SIZE);
		int sent = uart_fifo_fill(dev, data_tx, nr_bytes_read);
		printk("sent %d\n", sent);

		ring_buf_get_finish(&uart_rb, sent);
		if (ring_buf_is_empty(&uart_rb)) {
			uart_irq_tx_disable(dev);
		}
	}
	..
}

void uart_write(uint8_t* str, int len)
{
#if 1
	while (ring_buf_space_get(&uart_rb) < len) {
		printk("queue full, waiting for free space");
		k_sleep(K_MSEC(1));
	}
	
	uart_irq_tx_disable(lpuart);
	ring_buf_put(&uart_rb, str, len);
	uart_irq_tx_enable(lpuart);
#else
	uint16_t i;
	
	for( i = 0; i < len; i++) {
		uart_poll_out(lpuart, str[i]);
	}
#endif	
}

[RTT log] send 16 but target did not received anything.
00> sent 16



For Nordic kind support, we can make it not to late. Thank you. I hope this is to be last question.
Can you please give me guide. I have to prepare new firmware by the end of this week. Pre-mass production is scheduled.

+addition
I found uart_irq_tx_complete() returns '0' for more than 30 sec.(call it every 1 second)

Parents Reply Children
Related