Serial communication: Troubles, errors & performance problems.

My problem seems trivial, but I'm having huge troubles while trying to send file from PC to Arduino... The final goal is to transfer about 32KB at minimum speed about 33600bps without errors.

Let me tell what I've tested so far:

First I used Arduino UNO with 9600bps, 8N1 to read data from 10 bytes at a time and then it sent out 1-byte as "send me more data". The idea was that this way I don't overrun FIFO in any case... This works quite fine (as expected) until 12KB has been transferred... After 12KB the speed suddenly drops to ridiculous speed that is about 200bps. That is WAY too slow for my needs.

I found out that when I remove the 1-byte return value the speed will not mystically drop anymore, so now I send only 1-byte at a start as "GO, PC" and then the PC outputs all of the file to Arduino... This is fine, but not fast enough. Now when I change the speed to ie. 14400 or 33600bps the number of errors in transfer increases a lot and I need error free data. Going beyond 33600bps does not help much as this seems to be pretty close to maximum speed Arduino UNO can take (!?) from serial port. To fix these errors I tried sending each byte 3-times and selecting the value that appears same 2 times on Arduino end. This corrected the errors and verified that the problem is in between Arduino and PC, but yet again the communication is too slow. (Only little faster than with 9600 without errors)

I thought this might be some sort of hardware problem, so I uploaded same program to Arduino Pro Nano V3. With this device I can use any speed from 9600bps to 115200 without communication errors, but it seems that the actual throughput in serial port input is only about 2000bps (!?) that is even slower than Arduino UNO error free 9600 :frowning:

Can someone help me, what I can do to get this sorted out? Is this normal with UNO that there is errors at these speeds? Is there any other way to solve this on UNO except implementing some complex error correcting protocol? Is there a way to communicate 2-way without speed dropping to ~200bps after 12KB? Why the speed even drops? Is there a way to boost the communication on Arduino Pro Nano V3 beyond 2000bps?

The server side of this software is running on WinXP and it is written with VB6 using MSCOMM.

Thank you for your time. I really hope I can get this solved.

Where is 32k of data coming from or going to if the Uno only has 2k of ram?

I've had no problem sending data to/from an Uno at 115kbaud. I think I even got it to work at 1Mbaud using the Putty terminal rather than the Arduino serial monitor.

Show us your code - in code tags please (the # button above the edit window).

...R

Sorry for a bit late reply. I've had few crazy days. I just realized that my previous tests do not prove that the communication breaks at serial... It might just as well be broken down by my paraller protocol...

The data received from PC will be transmitted trough using 4-bit paraller protocol & 2-way clock (Output at rising edge).
This is the routine that fails on speeds greater than 9600... I just realized that it might be that the buffer overflows... I really have to get communication working 2 ways to PC...

void RAWsend()
{
    while(Serial.available() == 0) {}
    a=Serial.read();  
    while (digitalRead(Pin8)==LOW) {};
    DDRD = ((DDRD & 131)|(((~(a<<2)) & 60))+0);
    while (digitalRead(Pin8)==HIGH) {};
    DDRD = ((DDRD & 131)|(((~(a>>2)) & 60))+64);
    while (digitalRead(Pin8)==LOW) {};
    DDRD = ((DDRD & 131)|(((~(a>>2)) & 60))+0);
    while (digitalRead(Pin8)==HIGH) {};
    DDRD = ((DDRD & 131)|(((~(a<<2)) & 60))+64);
}

Your code won't compile. And why did you not use the code tags?

...R