Nano Every Serial port Sending Delay takes 43ms!

Why is it taking Nano Every 43ms to send on Serial1 ?
Can this be fixed ?


int Max485Send(int X1,int X2,int X3) {
    if (Serial1.availableForWrite() > 2) {
      Serial1.write(X1);
      Serial1.write(X2);
      Serial1.write(X3);
      Serial.print("S> (X1) "); Serial.print(X1);
      Serial.print(" (X2) "); Serial.print(X2);
      Serial.print(" (X3) "); Serial.println(X3);
    } else Serial.println("MAX485 Unavailable for Writing!");


  return 0;
}


void loop()
{ 
  int msec = millis();
  //Nodes poll for their ID and then process Fn and T1
  // and then respond.
  ID = 0;
  Max485Poll(ID,Fn,T1); // listen! but only to our programmed ID
  
  if (ID == MAX485ID) { //double check
    Serial.println("ID Matched!");
    Serial.print("R> elapsed "); Serial.println(millis()-msec); msec = millis();
      T1 = CurrentTime;
      ID = 0;
      Max485Send(ID,Fn,T1); 
      Serial.print("S< elapsed "); Serial.println(millis()-msec); msec = millis();

      Max485Send(ID,Fn,T1); 
      Serial.print("S< elapsed "); Serial.println(millis()-msec); msec = millis();
      
      Max485Send(ID,Fn,T1); 
      Serial.print("S< elapsed "); Serial.println(millis()-msec); msec = millis();
      
      Max485Send(ID,Fn,T1); 
      Serial.print("S< elapsed "); Serial.println(millis()-msec); msec = millis();
      
      }// if Fn
    }//if ID


   //eb1.update();

}

each call is taking 43 ms to reply, unlike the other AVRs that take 8 ms to send same code!

ID Matched!
R> elapsed 458778
S> (X1) 0 (X2) 3 (X3) 66
S< elapsed 458790
S> (X1) 0 (X2) 3 (X3) 66
S< elapsed 458789
S> (X1) 0 (X2) 3 (X3) 66
S< elapsed 458791
S> (X1) 0 (X2) 3 (X3) 66
S< elapsed 458790

Did you try to remove this condition?

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.