UART serial comms between Due and Mega - data structure differences?

Hi All,
I am sending 13 bytes from a Due to a Mega over the UART serial comms running at 1MHz. My code works when two Due's are talking together but when a Mega is receiving I appear to get 9 bytes back, with the first byte as expected but the rest incorrect.

I imagine that the two different processors require different data formats, but I don't have a clue about this. Code snippets are attached below for both Arduinos, including serial outputs.

sending Due code; (data[] is populated in code not shown, but triggered by a request from the Mega)

char data[13];

void setup() {
  Serial2.begin(1000000);
   Serial.begin(112500);
}

void SendMyserial()
{
  //send 13 bytes 
  for (int i=0;i<13;i++)
  {
    Serial2.write(data[i]);
  }
  Serial2.flush();
  for (int i=0;i<13;i++)
  {
    Serial.print(data[i],HEX);
    Serial.print(",");
  }
  Serial.println("");
}

Mega code for receiving data is below;

long i;
long istep = 1000;
void setup() {
  Serial2.begin(1000000);
  Serial.begin(112500);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (millis() > i+istep)
  {
    Serial2.write(0x3A); //send command to due to get data
    delay(5);
    while(Serial2.available() >0)
    {
      Serial.print(Serial2.read(),HEX);
      Serial.print(",");
    }
    Serial.println("");
    i = millis();
  }
}

The data sent by the Due is for example this; (13 bytes)
A2,1,4C,2A,40,0,0,85,F0,F0,F0,F0,F0,

and the same data as received by the Mega looks like this; (only appears to have received 9 bytes)
A2,C0,29,9,1,0,30,F0,F0,

The same code when used with two Dues produces expected results so I can rule out electrical noise and most other issues I think.
How do I fix my code? I have run out of ideas.
Thanks in advance,
Finlay

Often happens... as soon as you get to the point of posting for help, you find the answer yourself...

I forgot the level shifting between 3.3V and 5V on the serial interface. If I drop the speed from 1MHz down to 200kHz it works, which explains why two Due's worked together!

A quick fix, until I get level shifting sorted. Thanks for looking anyway.
Fin

I imagine the CPU speed difference may have a little to do with it also. The Mega may have trouble keeping up with a 1MHz serial port.
Mega = 16MHz
Due = 84MHz

Thanks for the tip - actually you pointed me to what I think is the real problem.

According to the processor datasheets the UART baud rate is defined by MCK/(16 x CD) where MCK is master clock speed and CD is clock divider which must be an integer. So for the Mega the maximum baud rate is 1MHz, with the next ones down being 500kHz, 333,333Hz etc... For the Due this equates to a maximum baud rate of 5.25MHz. If you take the highest common denominator between the Mega and the Due you end up at 250kHz which when tested gives trouble free communication. I haven't been able to find a set of multipliers that results in a higher common baud rate within an allowable tolerance of each other.

I think the following table highlights the issue.

Mega
divisor = 1 -> baud = 1Mhz
divisor = 2 -> baud = 500kHz
divisor = 3 -> baud = 333,333Hz
divisor = 4 -> baud = 250kHz

Due

divisor = 5 -> baud = 84/(16x5) = 1.05MHz (+5%)
divisor = 6 -> baud = 84/(16x6) = 875kHz (-12.5%)
divisor = 10 -> baud = 84/(16x10) = 525kHz (+5%)
divisor = 11 -> baud = 84/(16x11) = 477kHz (-12.5%)
divisor = 15 -> baud = 350kHz (+5.1%)
divisor = 16 -> baud = 328kHz (-1.5%) (this works intermittently)
divisor = 21 -> baud = 250kHz = MATCH! - works reliably

If there is anyone out there who knows how to get baud rates other than this for the Due (I want 1MHz) then I'd be grateful to know how.
Thanks again,
Fin