20MHz NewSoftSerial DELAY_TABLE

Using a combination of Excel, semi-intelligent guessing, and iteration, I created a DELAY_TABLE for use in NewSoftSerial.cpp on an Arduino using a 20MHz crystal. I don't have a logic analyzer and only have about 20 minutes of testing on this, but it seems to be pretty reliable up to 115200 baud RX and TX. Definitely welcome feedback, additional testing, and tweaks to any of the values.

#elif F_CPU == 20000000

static const DELAY_TABLE PROGMEM table[] = 
{
  //  baud    rxcenter   rxintra    rxstop    tx
  { 115200,       3,        21,       21,      18,  },
  { 57600,       20,        43,       43,      41,  },
  { 38400,       37,        73,       73,      70,  },
  { 31250,       45,        89,       89,      88,  },
  { 28800,       46,        98,       98,      95,  },
  { 19200,       71,       148,      148,     145,  },
  { 14400,       96,       197,      197,     194,  },
  { 9600,       146,       297,      297,     294,  },
  { 4800,       296,       595,      595,     592,  },
  { 2400,       592,      1189,     1189,    1186,  },
  { 1200,      1187,      2379,     2379,    2376,  },
  { 300,       4759,      9523,     9523,    9520,  },
};

#define XMIT_START_ADJUSTMENT 6

Nice work, macegr! This is a very useful contribution.

I have taken your work and incorporated it into NewSoftSerial 10 (currently available for testing at http://www.arduiniana.org).

Mikal

can we also get this to work on a 12mhz clock?

can i help in any way?

Thanks
Jeff