SoftwareSerial and unsupported baud rate

Hi,

I want to run a serial connection at 100'000 bauds but this is not supported by the SoftwareSerial library.
I tried to edit the SoftwareSerial.cpp to add values for 100'000 in the baudrate table but I don't get the correct values back.

#if F_CPU == 16000000

static const DELAY_TABLE PROGMEM table[] = 
{
  //  baud    rxcenter   rxintra    rxstop    tx
  { 115200,   1,         17,        17,       12,    },
  { 100000,   5,         27,        27,       22,    },
  { 57600,    10,        37,        37,       33,    },
  { 38400,    25,        57,        57,       54,    },
  { 31250,    31,        70,        70,       68,    },
  { 28800,    34,        77,        77,       74,    },
  { 19200,    54,        117,       117,      114,   },
  { 14400,    74,        156,       156,      153,   },
  { 9600,     114,       236,       236,      233,   },
  { 4800,     233,       474,       474,      471,   },
  { 2400,     471,       950,       950,      947,   },
  { 1200,     947,       1902,      1902,     1899,  },
  { 600,      1902,      3804,      3804,     3800,  },
  { 300,      3804,      7617,      7617,     7614,  },
};

I tried multiple values but I don't seems to pick the right one. Is there a way to compute them ?

Thank you

I tried multiple values but I don't seems to pick the right one. Is there a way to compute them ?

Theoretically you can compute them by adding up the execution times of all assembler calls made in the corresponding loop but you can guess them and measure the output to get a rather good result. But in these ranges you can just use 115200 from the default table and you get something in the area of 100k baud, SoftwareSerial isn't that exact anyway. If you want something a tiny bit more exact, I would use the values

{ 100000,   2,         19,        19,       14,    },

That might give you slightly more of 100k baud but as I said: don't use SoftwareSerial for anything above 19200 baud except if you have a very tolerant device on the other side.

software serial works only reliable if there are only few interrupts during communication. In my experiments under ideal conditions I saw that above 70000 baud SWSerial fails. I replaced the table with a formula, so any baud rate can be used. The advantage is that you can tune the baud rate a bit so instead of 38400 you can use 38500 to compensate deviations in clocks.

Read the details here - SoftwareSerial magic numbers - Libraries - Arduino Forum -

Thank you for your help!

Everything seems to work fine with those new values.