nrf-uarte problems with uart_irq_tx_disable() in handler #24479
Labels
bug
The issue is a bug, or the PR is fixing a bug
platform: nRF
Nordic nRFx
priority: medium
Medium impact/importance bug
The CDC_ACM sample uses an idiom for interrupt-driven UART that involves a loop that is repeated as long as an interrupt is pending.
This idiom does not work for
nordic,nrf-uarte
. (It works fornordic,nrf-uart
; I have not tested other platforms.) The failure is due to the invocation ofuart_irq_tx_disable()
within the application-provided handler. For UARTE this merely sets a flagdisable_tx_irq
, which is only inspected and acted upon in the FLIH that invokes the application-provided handler.Consequently though the code asked that transmit interrupts be disabled, when it loops back around
uart_irq_is_pending()
returns true, as doesuart_irq_tx_ready()
, which merely causes another attempt to disable transmit that is again ignored.The UART API is incompletely defined with respect to
uart_irq_update()
and its relation to the pending and ready checks: it says it must be invoked once per handler invocation, but does not address whether it needs to be invoked again if the handler implements a loop onuart_irq_is_pending()
.If the loop solution in CDC-ACM is legal code, then the Nordic UARTE driver should be fixed. A possible solution is to change the condition for
uarte_nrfx_irq_tx_ready_complete()
:This solves the problem in my code, but may have side effects that break other uses.
If the loop solution in the CDC-ACM examples is not legal code then it should be revised to avoid demonstrating a non-portable use of the interrupt-driven UART API.
The text was updated successfully, but these errors were encountered: