This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123GH6PM: (FreeMODBUS Implementation) UART Transmitter FIFO Empty Interrupt

Part Number: TM4C123GH6PM


Hello,

I'm currently implementing the FreeMODBUS library on the TM4C123GH6PM controller. I've run into an issue with the UART interrupts. A part of the implementation requires an interrupt service routine that is triggered whenever a character can be sent over the UART. So my understanding is that it should be triggered whenever the Transmit FIFO is empty. I'm trying to test my configuration through the USB emulator connection (UART0_BASE), however the ISR is never triggered due to an empty transmit buffer, and no data is ever sent. My question is, is it possible to implement such an ISR on this controller, and if so, what am I doing wrong? I guess that alternatively, I could poll the transmit buffer in the main loop to check if it is empty, and call the callback function from there, but I'd prefer to do it in an ISR, as per the FreeMODBUS requirements.

My UART configuration is as follows:

My ISR is set up as follows:

My UARTIntHandler is also correctly setup in the NVIC vector table.

Many thanks,

Ksawery

  • I just came across this post, which seems to indicate that the Tiva Launchpad cannot generate interrupts when the transmit FIFO is empty (only at the transition from >1/8 full to <1/8 full). So now i'm not sure what would be the best way to implement this? I thought that disabling the FIFO might work, but that didn't change anything. Should I poll the UARTBusy function continuously? Or perhaps I should send a  few bytes over the UART when I intialize it, to set the initial flags? That might create another problem though, since the application periodically disables and enables the UART RX and TX interrupts (code attached below).

    ***

    Transmit interrupts are a little bit different. Some microcontroller’s UARTs generate an interrupt when the transmit buffer is empty.  This interrupt is meant as an indication that the application can send the next byte over the UART.   What we want to avoid is the situation where the application is not transmitting data and, as a result, the UART constantly generates transmit empty interrupts. This situation would starve the application because the UART handler would be executed constantly.  If the microcontroller you are using constantly generates Tx empty interrupts when no data is in the Tx hardware FIFO,  you can use the following  process to eliminate the starvation of the main application.

    1. The UART handler disables its own transmit empty interrupts when the UART’s transmit circular buffer is empty.  This prevents a continuous flow of interrupts
    2. When the application wishes to send data, it adds the data to the UART FIFO and then re-enables transmit empty interrupts.

    The Tiva Launchpad does not behave this way. The Tx Empty interrupt is only generated when we pass through the FIFO interrupt level.  Lets say that our interrupt level is set at 1/8th full.  The only time a Tx empty interrupt is generated is when the hardware FIFO transitions from holding 3 characters to holding only 2 characters.  When the FIFO is completely empty, no Tx empty interrupt is generated.

    ***


    Many thanks,

    Ksawery

  • Hi,

      You have a similar post that I just answered. https://e2e.ti.com/support/microcontrollers/other/f/908/t/816631 Let's use that post to continue the conversation. I will close this one. 

  • Hi Kaswery,

      Can this thread be closed as well since you closed the other thread https://e2e.ti.com/support/microcontrollers/other/f/908/t/816631?

  • Hi Kaswery,

      Regarding your UART interrupt query I think this is resolved in the other post  https://e2e.ti.com/support/microcontrollers/other/f/908/t/816631. I will close this thread here. If you have other questions please create a new posts. 

      I wanted to give a heads up that I'm out of office for a week starting tomorrow with limited access to the forum. Please open new threads so our support team can assist you. If you post new questions or reply to this post then I'm afraid our support team may not follow it.