Skip to main content
Graduate II
September 11, 2024
Solved

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

  • September 11, 2024
  • 3 replies
  • 2377 views

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

 

 

 

 

 

    This topic has been closed for replies.
    Best answer by Kvang

    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

     

     

    3 replies

    Super User
    September 11, 2024

    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) ... ?

    Super User
    September 11, 2024

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

    KvangAuthorAnswer
    Graduate II
    September 11, 2024

    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