Overflow UART - Arduino - Serial port

Hello,

The project is writing and reading (on/from) a 1Mb memory with I2C. We have used the Panamahitek library in Java for communicating with Arduino and serial port. It can read and write (from/on) the memory of about 4 to 5 minutes. But we miss some addresses during this process. I think the main reason is getting full of UART buffer. With adding delay, the problem is disappearing but it takes time a lot about 45 minutes or 1 hour. How can I solve the problem? (It is working very slowly)

I appreciate any help,

Golnaz

Code_Arduino.txt (10 KB)

Serial.begin(200000); //Serial port initialisation

Generally many errors occur when using speeds above 115200 for serial communication with low quality cables, especially in noisy environments, noisy power supply also harms.

To avoid data jamming, you can use a traffic control, usually the receiver responds that they are ready to receive more data, flow control can be done by software or hardware, in case of simple serial port (only with RX and TX) will have to be via software.

Is it Arduino which is reading data from a 1Mbyte capacity EEPROM using I2C Bus and then sending them (the data) to a destination (PC or whatever it is) using UART Port? Put your sketch on line with code tags (</>). What is the type number of the EEPROM?

I have never had a problem operating at 500,000 baud between my Arduino and my PC programs. Nowadays they are written with Python but a while back I was using JRuby which is based on Java. I don't recall ever taking any trouble to select my USB cables.

Can you write a short program that illustrates your problem? Problems like this should be eliminated long before a program grows to 10k in size.

...R

Thanks, rtek100 for your response!
Also, I have checked with different baud rate and the same problem is appearing (115200 and lower). Can you guide me more using traffic control by software?

Thanks, GolamMostafa for your response!

Yes, exactly. For the first time, I want to write on the memory and in the next step reading all addresses with their values.

This is the memory that I have used: CYPRESS CY14B101J_ 1-Mbit ( 128K * 8 ) Serial (I2C) nvSRAM.

Thank you Robin2 for your response. This is the main part of the program that we are going to write on the memory and then reading on the memory.

int8_t I2C_readByte(uint32_t address) { //HECHA

  uint8_t value;
  uint8_t addr_xhi;
  uint8_t addr_lo;
  uint8_t A16;
  int deviceAdd;
    
  A16 = (address >> 16) && 0x01; // Bit A16
  addr_xhi=(address >> 8);// Bits A8-A15 
  addr_lo=(address & 0xFF); // Bits A0-A7
  
  if(A16 == 0) deviceAdd = 80;
  else if (A16 == 1) deviceAdd = 81;
  else{ 
    Serial.println("ERROR, Invalid device address");
    return -1;
    }

  Wire1.beginTransmission(deviceAdd); 
  Wire1.write(addr_xhi);
  Wire1.write(addr_lo);

  Wire1.endTransmission(false);
  Wire1.requestFrom(deviceAdd,1); 
  

  if(Wire1.available() == 0) Serial.println( "Not available");
  else{
  value = Wire1.read();
  //Serial.print( " -> OK <- Read Address: ");
  Serial.print(address);
  Serial.print( ":");
  Serial.println(value);
  Serial.print("*");
  //delay(30);
  }
  
  return value;
  
}
  
void I2C_writeByte(uint32_t address, uint8_t data_byte) {
  

  uint8_t value;
  uint8_t addr_xhi;
  uint8_t addr_lo;
  uint8_t A16;
  int deviceAdd;
    
  A16 = (address >> 16) && 0x01; // Bit A16
  addr_xhi=(address >> 8);// Bits A8-A15
  addr_lo=(address & 0xFF); // Bits A0-A7
  
  if(A16 == 0) deviceAdd = 80;
  else if (A16 == 1) deviceAdd = 81;
  else{ 
    Serial.println("ERROR, Invalid device address");
    return;
    }
 
  Wire1.beginTransmission(deviceAdd);
  Wire1.write(addr_xhi);
  Wire1.write(addr_lo);
  Wire1.write(data_byte);
  if(Wire1.endTransmission() != 0) Serial.print(" -> ERROR <- ");
  //else Serial.print(" -> ERROR <-");
  //Serial.print( " Write Address: ");
  Serial.print(address);
  Serial.print( ":");
  Serial.println(data_byte);
  Serial.print("*");
  delay(15);

 
}

g_krn:
Thank you Robin2 for your response. This is the main part of the program

It needs to be a complete testable program.

...R

Robin2, sorry I couldn't understand your meaning. I had sent all the program yesterday. Please let me know what you mean?

g_krn:
Robin2, sorry I couldn't understand your meaning. I had sent all the program yesterday. Please let me know what you mean?

I thought your Reply #6 was a response to my suggestion in Reply #3 to write a short program that illustrates the problem.

For example, I have been working on a Python program that uses a browser. There was a big problem with one part when I tried it on Windows. Writing a 17 line HTML file enabled me to understand the problem and devise a solution.

...R

g_krn:
Thanks, rtek100 for your response!
Also, I have checked with different baud rate and the same problem is appearing (115200 and lower). Can you guide me more using traffic control by software?

Maybe this post can give you some direction about this:

This article will explain the following topics in details:

  1. Step 1: Understand RS232 Connection and Signals
  2. Step 2: Learn about the Protocol
  3. Step 3: Control your RS232 devices by using 232Analyzer
A16 = (address >> 16) && 0x01; // Bit A16

or

A16 = (address >> 16) & 0x01; // Bit A16

?