I have an application where I need to support communications at 115kbaud, 250.8kbaud, and 2.08Mbaud on the same serial port (one at a time, of course). I connect at 115K and negotiate with the other device to go faster.
To make life interesting, these baud rates are not related to each other, so I can’t find a single oscillator that will work, and I doubt the ATMega that I want to use would like having its clock changed on the fly.
Any good ideas how to do this? I’m leaning towards an external i2c uart and two oscillators or muxing between the ATMega’s uart for 115k and an external one for the other two rates.
I’m not familiar with the ATMega - does the chip you’re using have an internal oscillator that can be switched to/from under program control? If so, you could safely switch between multiple external oscillators by temporarily running from the internal oscillator during the switch. This would be easiest if you used oscillator modules with an output enable pin, their outputs could simply be connected together (just be very, very sure that you never enable more than one at a time!).
I’m not sure an I2C UART is going to work well at 2.08 Mbps - the UART would have to have a large buffer, and your protocol would have to have a low duty cycle, for that to work at all.
I’m looking at the SC16IS740 UART; it will do 5Mbits. It has a 64 byte FIFO, and my messages are small, so that shouldn’t be a problem. Since it has its own clock input, I should be able to change clocks and issue a reset to the UART, so even if it gets confused during the clock change, I can clear things.
The brief period while it gets reset isn’t a problem.