Skip to main content
Associate II
February 23, 2026
Question

STM32N6 with ThreadX. What is the most efficient way to process UART Rx?

  • February 23, 2026
  • 1 reply
  • 215 views

Hello,
I hope someone with more experience with the STM32N6 and ThreadX can help me get an efficient solution.
I'm using STM32N6 to communicate with multiple peripheral devices via UART. The protocol they are using to send data however, does not allow me to know what the message is in advance, or how many bytes the received packet would be. I only know the packet ends with 0x0D 0x0A. 
Other MCUs I've used in the past have some built in Pattern matching in the DMA so the DMA interrupts when a combination of symbols is received (0x0D 0x0A). However I don't see something like that in the STM32N6 HAL. I did a driver using the simple HAL_UART_Receive_IT(huart, &UART2_rxByte, 1); and interrupt on every byte to check if a packet is received, but It is really painful to know CPU time is wasted on entering interrupts when I need it for processing data. Maybe ThreadX can be more efficient with some polling thread? Or I missed some configuration option? What would you suggest?

1 reply

Andrew Neil
Super User
February 23, 2026

@Roshko wrote:

 interrupt on every byte to check if a packet is received, but It is really painful to know CPU time is wasted on entering interrupts 


So don't do the checking in the ISR.

Just have the ISR write to a circular buffer.

Parse the buffer elsewhere ...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
RoshkoAuthor
Associate II
February 23, 2026

That doesn't solve my issue of processing time wasted for entering the ISR on every byte. Can I have the DMA do it? Is there a HAL function to get the new buffer entries? Or at least a pointer to the last entry? 

Andrew Neil
Super User
February 23, 2026

The amount of time to simply get the received character and put it into the ring buffer is minimal.

Doesn't the N6 have FIFOs in its UARTs?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.