cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 UART - use FIFO and get per-character interrupt?

Kvang
Associate III

Hi 

The MCU is a STM32H735

I will use the UART3 port for combined debug output and command line interface
So I would like to use the FIFO, it quite useful when sending debug data.
The Fifo is also useful for RX, if e.g. interrupt is blocked by other interrupt with higher priority 

But I would like to have interrupt on every byte that I receive. That's needed for the command line interface where I echo and edit, finish, recall commands.

I have not been able to configure it like this. 

I do not need to use the Hall libraries, I can just implement a simple ring-buffer myself.

Is it possible to both use the Fifo and have interrupt on every bytes received?

Best Regards

Kristian Vang

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kvang
Associate III

Thanks for the inputs :)

I figured it out myself, the UART has separate interrupt flags for both Data available (RX) Empty(TX) Fifo levels.

So i was just a matter of enabling the correct flags

Now I can have it running as I want by interrupt alone.

__HAL_UART_ENABLE_IT(m_huart, UART_IT_RXNE); // Enable RX interrupt

__HAL_UART_ENABLE_IT(m_huart, UART_IT_TXE); // Enable TX interrupt

 

 

View solution in original post

3 REPLIES 3
Andrew Neil
Evangelist III

Having an interrupt on every received byte seems to defeat the object of a FIFO?

:thinking_face:

 


@Kvang wrote:

The Fifo is also useful for RX, if e.g. interrupt is blocked by other interrupt with higher priority 


But you said the RX is for a CLI - so a human typing at a terminal?

Humans don't type fast (in microcontroller terms) - so this seems unlikely to be an issue?

Can you configure the UART with FIFO on TX only (not RX) ... ?

Pavel A.
Evangelist III

Probably you need here the receive timeout interrupt (RTO). It will allow receiving single characters even in FIFO mode.

Kvang
Associate III

Thanks for the inputs :)

I figured it out myself, the UART has separate interrupt flags for both Data available (RX) Empty(TX) Fifo levels.

So i was just a matter of enabling the correct flags

Now I can have it running as I want by interrupt alone.

__HAL_UART_ENABLE_IT(m_huart, UART_IT_RXNE); // Enable RX interrupt

__HAL_UART_ENABLE_IT(m_huart, UART_IT_TXE); // Enable TX interrupt