- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need to synchronize sending some data on a UART to some other events. I therefore need to know when the UART have completed sending all data in the SW buffer. I am using the regular UART in Quartus 13.1 and the regular altera_avalon_uart_driver for Nios II. How can I make a call that will block until the data is sent or get an interrupt when it is sent?
Here are some things I have tried.
I have tried opening the UART with fopen, sending data with fputs and waiting for all data to be sent with fflush. fflush returned almost immediately and long before all data was sent so fflush did not work for this purpose. I have also tried different types of buffering with setvbub. I have tried different variations of the open and write functions. I see there is a function called tcdrain that is supposed to, from my understanding, wait until all data is sent. It is actually just a macro # define tcdrain(fd) _ioctl (fd, _TCSBRK, 1). But it does not link since it can not find _ioctl. I have tried using ioctl (fd, _TCSBRK, 1) but it did not wait until the data was sent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
May be you can try to access these uart core control register bits for interrupt. Can refer to this manual (page 145).
Best Regards
Sheng
p/s: If any answer from community or Intel support are helpful, please feel free to mark as solution and give Kudos.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Have you try with UART operating in blocking mode using fcntl() command.
https://stackoverflow.com/questions/914463/how-to-make-a-file-descriptor-blocking
https://code.activestate.com/recipes/577384-setting-a-file-descriptor-to-blocking-or-non-block/
Regards,
Sheng
p/s: If any answer from community or Intel support are helpful, please feel free to mark as solution and give Kudos.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can make the UART operate in blocking mode using fcntl(). In blocking mode, a call to write something to the UART will block if the SW buffer is full. Unfortunately what I need to know is when the SW buffer empties. In altera_avalon_uart.h I see that the size of the SW buffer for both RX and TX is set to ALT_AVALON_UART_BUF_LEN. If edit this to two, one did not work, I get almost what I want. Unfortunately It also sets the RX buffer to a low value for this UART and both RX and TX buffer of all the other UARTs to a lower value than I like. I can probably make my own driver where I resolve this issues. But for now I think I will just bypass the driver and access the UART registers directly to achieve what I need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
May be you can try to access these uart core control register bits for interrupt. Can refer to this manual (page 145).
Best Regards
Sheng
p/s: If any answer from community or Intel support are helpful, please feel free to mark as solution and give Kudos.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, by bypassing the driver, accessing the device registers directly and using my own interrupt routine I was able to achieve what I needed.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page