Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

communication about niosii uart

Hi,

First,I'm sorry for my poor English.I am using the nios ii uart to communicate with pc,I want to receive the data from pc in interrupt.I am using the RRDY interrupt now,the question is I can only receive one data in one interrupt,when I try to receive more datas,the receive sentence run forever,but I can receive many datas when I do not use interrupt,how can I receive many datas in one interrupt?

Thank you for your reply!

4 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    The basic UART has a single character buffer, so the usual approach is to have the UART generate a RRDY interrupt when a new character is received, which you must read before the next character is received. So, the first character generates a RRDY interrupt, your ISR reads that character and may store it in a FIFO buffer in RAM, then returns from the ISR. The next character then generates another interrupt and so on. You can then process characters from the FIFO outside your ISR.

    When the NIOS forum comes back online, you could search that for lots of information regarding this type of UART handling. Also, you may read there about a FIFO'd UART which I haven't used myself, but may well offer the type of behaviour you are after (I guess it handles the transfer of received characters into a FIFO in hardware).

    Hope this helps

    Sharkybaba
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    Thank you for your reply,when I do not use interrupt,I can receive many datas one time use the function fread,I want to kown if there is another interrupt other than RRDY which can receive many datas?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi

    As far as I know, fread() works by implementing exactly the kind of RRDY interrupt and FIFO buffer as I described, and it does it in software.

    As well as the FIFO'd UART I mentioned, there may be a technique using a DMA component linked to the UART which could be used to generate an interrupt after a set number of characters have been received.

    The NIOS forum is back up now, so I'd suggest searching there for information on the FIFO'd UART.

    Cheers

    Sharkybaba