+ Reply to Thread
Results 1 to 2 of 2

Thread: UART background oparation

  1. #1
    New Member New Member LucklessLuke is on a distinguished road
    Join Date
    Sep 2016
    Posts
    1
    Points
    15

    UART background oparation

    Hello,
    I'm trying to implement serial interface with the lowest possible processor load.
    Should I use DMA or Interrupts. If interrupts are the option, how do I implement handler on data receive event if there's no IRQ handler available for the user in UART DAVE APP.
    There's only event on successful receive declared number of bytes, but how would I know, how many bytes to receive? I don't want to check if there's data in buffer in a loop, like it's in all exaples.

  2. #2
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    DRubeša will become famous soon enough
    Join Date
    Jul 2016
    Location
    München
    Posts
    193
    Points
    775.625
    Hi,

    there is a plenty of ways to achieve the successful receive but none of them is optimal from a "lowest possible processor load" point of view. UART is very simple protocol that requires polling or you need to know what is number of bytes you´ll receive.

    To answer your first question, you should use DMA. But you want to have full benefit of using DMA (auto increment, interrupt on received block...), so you should used UART and DMA APP. You will have some code overhead because of the DMA configuration, but in the long run you should benefit from it. If this is too much work or too complicated than you use Interrupt handling.

    The basic approach would be to use receive function with number of expected data 1. Then you would enter the interrupt handler every single time once 1 byte is received. This approach however is not very effiecient (CPU needs to enter interrupt handler constantly) and you could miss a next data while you´re still processing interrupt handler. To avoid entering interrupt handler so often (meaning to lower the CPU usage), you can use FIFO buffer. Let´s say you define that interrupt occurs once the 10 bytes are received. The problem is what if you receive only 5 or 9 bytes? No interrupt will be generated and you have a problem. Still, you could miss a data while you´re processing the interrupt handler.

    Now you can see, why I said that it´s very important in UART to know how many bytes you´ll receive to use some more efficient approach then polling. Most "famous" application of UART, communication with terminal, uses polling while we don´t know number of characters user will enter in the terminal.

    So, as you can see there is not best answer for your question. You need to see what suits best your application.

    Bets regards,
    Deni
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

+ Reply to Thread

Tags for this Thread

Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.