Serial data is received using the hardware USART module in the Mega8.
The serial format is 8n1 (8 bits, no parity and one stop bit).
Regular polling of the 'Receive Complete' flag determines if a character has been received.
The 'RX Complete Interrupt' is not used as it would cause glitches in the carefully timed composite video signal.
The polling is carried out (at least) once per scanline. This means that baud rates of up to 140k are possible before characters might be missed. That is not to say that 140k baud is actually useable - The useable rate is half this because some characters cause more complex routines to be called, some of which take (the character processing areas of) two scanlines to complete. More details on this can be found in the Control Sequence Handling section.
The baud rate is directly controlled by the state of jumpers J1, J2 and J3:
If the jumpers indicate autobauding, the device will go into 'autobauding' mode prior to displaying the screen. In the autobauding mode, the device will listen to the serial line and work out the shortest time between the first 8 state transitions it hears. This time is then used to work out the correct baud rate to use.
Note: Note that if no state transitions occur, the device will remain in the autobaud mode.
This autobauding method is not infalible. There are characters where all the gaps between transistions are more than one bit long (hence the baud rate selected will be incorrect). For most uses though, it works well, particularly as any top-bit-clear character (e.g. any ascii code less than 128) will contain a single-bit transition. A useful character to send for autobauding purposes is 'U'. Its bit pattern is 01010101, hence will complete the autobauding process in a single character.
The remaining bits of a character that was partly consumed by the autobauding process may cause framing errors (or similar). It's suggested that a short pause (a character or two in length) is used to allow the Serial module to re-synchronise.
Because the autobauding process uses the same timer as the main 64us video scanline interrupt, it is not possible to generate the video signal at the same time. The video signal is started as soon as the autobauding process is complete (hence the timer is available).
It can be used where the source's clock is not necessarily accurate - as long as it's consistent.
Almost any AVR running on its internal R/C clock can be (relatively easily) persuaded into generating simple serial data. As long as the R/C clock doesn't drift more than a percent or so from when autobauding was completed, then it will work fine. Obviously, sources where temperature and/or Vcc variations are common might have problems (although this could be mitigated somewhat by careful periodic autobauding).