Commit e235e7b3 authored by Krzysztof Chruściński's avatar Krzysztof Chruściński Committed by Benjamin Cabé
Browse files

drivers: serial: nrfx_uarte: Fix spurious RXTO event

Fast instance in nrf54h (uart120) can generate a spurious RXTO event
some time after RXTO event that indicates that RX path is disabled.
The time when event is generated depends on baudrate and when slower
baudrates are used peripheral is disabled on time to not notice it
in the test but with higher baudates issue become visible. In order
to avoid spurious interrupt, RXTO interrupt is disabled during RXTO
event handling and enabled when RX is enabled. This workaround is
applied only for fast instance to avoid unnecessary register
accesses for slower instances.

Signed-off-by: default avatarKrzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
parent 972ec824
Loading
Loading
Loading
Loading
+14 −0
Changes for drivers/serial/uart_nrfx_uarte.c: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -1165,6 +1165,14 @@ static int uarte_nrfx_rx_enable(const struct device *dev, uint8_t *buf,

	nrf_uarte_rx_buffer_set(uarte, buf, len);

	if (IS_ENABLED(UARTE_ANY_FAST_PD) && (cfg->flags & UARTE_CFG_FLAG_CACHEABLE)) {
		/* Spurious RXTO event was seen on fast instance (UARTE120) thus
		 * RXTO interrupt is kept enabled only when RX is active.
		 */
		nrf_uarte_event_clear(uarte, NRF_UARTE_EVENT_RXTO);
		nrf_uarte_int_enable(uarte, NRF_UARTE_INT_RXTO_MASK);
	}

	nrf_uarte_event_clear(uarte, NRF_UARTE_EVENT_ENDRX);
	nrf_uarte_event_clear(uarte, NRF_UARTE_EVENT_RXSTARTED);

@@ -1637,6 +1645,12 @@ static void rxto_isr(const struct device *dev)

#ifdef CONFIG_UART_NRFX_UARTE_ENHANCED_RX
	NRF_UARTE_Type *uarte = get_uarte_instance(dev);
	if (IS_ENABLED(UARTE_ANY_FAST_PD) && (config->flags & UARTE_CFG_FLAG_CACHEABLE)) {
		/* Spurious RXTO event was seen on fast instance (UARTE120) thus
		 * RXTO interrupt is kept enabled only when RX is active.
		 */
		nrf_uarte_int_disable(uarte, NRF_UARTE_INT_RXTO_MASK);
	}
#ifdef UARTE_HAS_FRAME_TIMEOUT
	nrf_uarte_shorts_disable(uarte, NRF_UARTE_SHORT_FRAME_TIMEOUT_STOPRX);
#endif