- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm using rs232 uart in nios. I'm using the open and read functions to recive data from the uart. I'm using the serial port monitor in order to send data on rs232 from the computer to the board. The thing is when using the read function I only get the last byte from the string. For example, if sending "abcd" from the serial port the read function will return only "d". Any idea what could be the problem? Thanks, MerabiLink Copied
9 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Amost certainly the uart has no receive fifo so the bytes are being overwritten before being read.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yeah I thought of that but when adding the RS232 UART in SOPC there is no such option as FIFO so I thought it's automatically.
maybe this kind of UART has no FIFO at all?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is a fifo'd uart available somewhere.
Might not be from Altera, check the wiki. The other option is taking interrupts and using a software fifo. But that probably uses more code than the hardware fifo! The other option would be a uarth that with an avalon master interface using external memory for its fifo - but I doubt that exists.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I will try that, thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Problem solved, thanks!
I was working with breakpoints and was sending the data to the uart while stopped at breakpint so the hardware went on and the software was stopped. My guess is that the counter of the buffer in the uart is precended in the software so when stopped at the breakoint the UART thought we were at the same place as before eventhough a new character was recieved into the rx register.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- Problem solved, thanks! I was working with breakpoints and was sending the data to the uart while stopped at breakpint so the hardware went on and the software was stopped. My guess is that the counter of the buffer in the uart is precended in the software so when stopped at the breakoint the UART thought we were at the same place as before eventhough a new character was recieved into the rx register. --- Quote End --- I have met the same problem. Can you explain more detail or share your code? Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, yes.
The problem I had is that I used breakpoints. My guess is that in that case when the first byte arraived the software stopped at the breakpoint while the hardware kept on recieving additional bytes. So, the counter of the software did not go on but the hardware updated the current byte as new bytes arrived so only the last byte was kept at the register in the end of the process. The code is the usual code that is shared usually here, I just can't copy it at the moment. Just don't use breakpoints and you'll be fine. If you want to "samplew" the progress of your software then try writing somethings to the uart.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- Hi, yes. The problem I had is that I used breakpoints. My guess is that in that case when the first byte arraived the software stopped at the breakpoint while the hardware kept on recieving additional bytes. So, the counter of the software did not go on but the hardware updated the current byte as new bytes arrived so only the last byte was kept at the register in the end of the process. The code is the usual code that is shared usually here, I just can't copy it at the moment. Just don't use breakpoints and you'll be fine. If you want to "samplew" the progress of your software then try writing somethings to the uart. --- Quote End --- where is the code that you have mentioned?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is an example to detect some characters:
char* msg = "Detected the character 't'.\n"; FILE* fp; char prompt = 0; fp = fopen ("/dev/uart1", "r+"); //Open file for reading and writing if (fp) { while (prompt != 'v') { // Loop until we receive a 'v'. prompt = getc(fp); // Get a character from the UART. if (prompt == 't') { // Print a message if character is 't'. fwrite (msg, strlen (msg), 1, fp); } } fprintf(fp, "Closing the UART file.\n"); fclose (fp); } return 0;
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page