Arduino Uno can't get valid data on baudrate 230400 8E1

Dear Sir,

I’m doing a project by using Arduino Uno to send command to display (LCD display for mazda3)
and Arduino can’t get valid data on baudrate 230400 8E1

In Functional spec.of Display, when send command that’s including data 39bytes on baudrate 230400 8E1 as below

PacketCommand[39]={0x79,0x04,0x00,0x22,0xF0,0x01,0x4A,0x33,0x36,0x61,0x77,0x56,0x6A,0x6C,0x59,0x61,0x73,0x75,0x48,0x61,0x79,0x61,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6C}

, Then the display will return data back 8bytes = 0x79,0x06,0x00,0x03,0xF1,0x01,0x01,0x75
I’ve checked with PC on baudrate 230400 8E1, it’s getting valid data

But when i use Arduino to send above command on baudrate 230400 8E1 to the display then The display return data back just 4bytes 0x79,0x03,0xFC,0x03,that is wrong answer

Could you advise me.
PS. I’m wondering Arduino Uno can’t get valid data on baudrate 230400 8E1

Best Regards
KP

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

////////////////////////////////////////////////////////////////////////////////
void setup() {
  lcd.begin(16, 2);
  //230400 SERIAL_8E1
  Serial.begin(230400,SERIAL_8E1);

  lcd.setCursor(0, 0);
  lcd.print("press select btn.  ");

}
////////////////////////////////////////////////////////////////////////////////
void loop() {

/*=====TEST MODE ENTRY=====  */
  byte PacketCommand[50]={0x79,0x04,0x00,0x22,0xF0,0x01,0x4A,0x33,0x36,0x61,0x77,0x56,0x6A,0x6C,0x59,0x61,0x73,0x75,0x48,0x61,0x79,0x61,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6C};

  int x = analogRead(A0);
  byte RevBuffer[100];
  unsigned int Lenght;

 //select button
if (x < 900 && x > 700){
  //transmit data
  lcd.clear();
  lcd.setCursor(0, 1);
  lcd.print(" send data.....   ");
  
  Serial.write(PacketCommand,sizeof(PacketCommand));
  Serial.flush();

}

delay(500);

//Receive data
  if (Serial.available())
  {   
    delay(5);
    Lenght = Serial.available();
    Serial.readBytes(RevBuffer, Lenght);
    //Serial.setTimeout(1000);

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print ("Rev= ");    
    lcd.print (Lenght); 
    
    lcd.setCursor(0, 1);
    
    for (int i = 0; i < Lenght; i++){
    lcd.print (RevBuffer[i],HEX);
    lcd.print (",");
  
    }
    Serial.flush();

  }

}

http://www.wormfood.net/avrbaudcalc.php

230400 baud has an error of 7.8% (locate the 16 Mhz table).

Use a different baud. 250000 is an excellent choice.

According to the datasheet at 230400 baud there will be an error of 3.5% in the baud rate however the maximum recommended error is 1.5%.

Can't you operate at a lower baud rate?

230400 baud has an error of 7.8% (locate the 16 Mhz table).

I saw 8.5% or -3.5% in my datasheet.

Now I may be wrong here but I suspect that the serial class does not implement the form
write(*buffer, size).
I think you'll find that what is happening is that serial is just dropping your size parameter and treating the call as write(char*buffer) and therefore stopping once it finds the first zero in your buffer.

Try sending it a byte at a time instead.

Dear Sir,

thank you for your answer

In term of display interface,
Baudrate should be 230.4 kbps +-1.5% ,8bit LSB first ,parity EVEN

is there any way to fix it?
change 16Mhz to another?

Best Regards
KP

Can you provide a link to this? It seems incredibly fast for updating a display in a noisy environment.

Dear Nick Gammon,

I can't give you the link. because I just have only UART interface config as below

Baudrate should be 230.4 kbps +-1.5% ,
8bit LSB first ,parity EVEN

thank you for your kindly

can we change Xtal 16Mhz to another for solving it

Best Regards
KP

can we change Xtal 16Mhz to another for solving it

14.7456 Mhz would give 0.0% error.

CPU speed would have to be accounted for in the board file (and elsewhere?) so timer functions work correctly.

http://www.wormfood.net/avrbaudcalc.php

Sittipong:
I can't give you the link. because I just have only UART interface config as below

Baudrate should be 230.4 kbps +-1.5% ,
8bit LSB first ,parity EVEN

Yes, but how do you know this? Was it a dream? Where did you get this information?

It's my company knowledge it's confidential
in more detail without this
i can't give you

so sorry
KP

dlloyd:
14.7456 Mhz … timer functions work correctly.

Only if the timer functions are rewritten.