When I send a data stream from my PC to a CP2102 USB-to-Serial Bridge, the data coming out of the RS232 side is sometimes corrupted. The receiving micro (an ATmega2560) reports frame errors when this happens.
I send a command of 30 characters every 180ms. for every 10000 commands there are around 15 to 30 failures.
I use 9600.8N1, so a start bit plus 8 data bits should take 0.9375ms. Flow control is set to None.
It is always the first byte and sometimes (1 in 20) the second byte that is corrupted. I've captured the data on an oscilloscope and measured the byte times (beginning of start bit to beginning of first stop bit).
If I have corrupted data, the time is around 1.000ms. Good data takes between 940us and 960us.
It is always the last few data bits (i.e. the highest bits) and the stop bit that is the problem.
See image below for an example of the second byte being corrupted:
The character between the vertical cursor lines should be a 'P', but it takes 1.000ms and is received as 0xd0 instead of 0x50. The byte before it is a '*' (0x2a) and is fine, it takes 0.940us.
What could cause these frame errors?