Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12589 Discussions

nios rs232 uart reads only last byte

Altera_Forum
Honored Contributor II
1,450 Views

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
Altera_Forum
Honored Contributor II
355 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
Altera_Forum
Honored Contributor II
355 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
Altera_Forum
Honored Contributor II
355 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
Altera_Forum
Honored Contributor II
355 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
Reply