Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Valued Contributor III
1,101 Views

nios rs232 uart reads only last byte

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, 

Merabi
0 Kudos
4 Replies
Highlighted
Valued Contributor III
6 Views

I guess this is due to the fact the uart is unbuffered, then you must read the incoming data faster than it arrives

0 Kudos
Highlighted
Valued Contributor III
6 Views

I see..that was my guess too, just wanted to see if anyone ever ran into that too. 

When adding the UART in the sopc I can assign to it an IRQ..Do you know if that will cause an interrupt every time a new byte will be recieved in the UART? 

(of course I will have to make sure that the reading process will be faster than the baud rate)
0 Kudos
Highlighted
Valued Contributor III
6 Views

 

--- Quote Start ---  

I see..that was my guess too, just wanted to see if anyone ever ran into that too. 

When adding the UART in the sopc I can assign to it an IRQ..Do you know if that will cause an interrupt every time a new byte will be recieved in the UART? 

(of course I will have to make sure that the reading process will be faster than the baud rate) 

--- Quote End ---  

 

 

Unless you're turning off interrupt handling (masking them) for long periods or you have Interrupt Service Routines taking longer than a few microseconds, there's no chance of not keeping up with 115200 baud even when using interrupts on unbuffered UARTs. However, buffered UARTs are MUCH more efficient because you can make them low priority interrupts and run faster than 115200. For the safest approach unless you absolutely need the serial speed, run somewhere slower like 38400 or 19200. 

 

BillA
0 Kudos
Highlighted
Valued Contributor III
6 Views

 

--- Quote Start ---  

Unless you're turning off interrupt handling (masking them) for long periods or you have Interrupt Service Routines taking longer than a few microseconds, there's no chance of not keeping up with 115200 baud even when using interrupts on unbuffered UARTs. However, buffered UARTs are MUCH more efficient because you can make them low priority interrupts and run faster than 115200. For the safest approach unless you absolutely need the serial speed, run somewhere slower like 38400 or 19200. 

 

BillA 

--- Quote End ---  

 

 

Hi, 

Thanks! 

Actually i'm not doing anything for now but receiving bytes imfrom the uart. 

I'm working with 19200 baud rate. 

The thing is that the interrupt mode not seems to work. I'm still receivig only the last byte from each string. 

I unchecked the small c library and the reduced driver and still not able to recieve all the characters. 

Any idea why is that happening?
0 Kudos