AN00003.TXT Advanced Communication Board Developer's Toolkit 1995 ---------------------------------------------------------------------- ---------------------------------------------------------------------- Subject: Z85x30 SCC Recovery Time. Due to the nature of a device that synchronizes access to two asynchronous events (namely the PC expansion bus and incoming serial data) a timing requirement is introduces to allow internal device registers to update. This application note is dedicated to the discussion of the Zilog 8530, 85C30 and 85230 recovery time requirements. The source code for several programs on this diskette contain the statement "JMP $+2" in between sequential I/O access to the 8530 SCC. This assembly language instruction does nothing but jump to the next instruction waiting to be executed. This small jump causes the CPU to purge the contents of the instruction pre-fetch queue (that happens before any jump instruction). When several (between 4 and 8 for 386DX and 486DX machines) of these instructions are executed consecutively, the result is an efficient delay that is long enough to guard against SCC recovery time violation. The length of SCC recovery time is 4PClks. The PClk on a standard ACB is 4.9152 MHz. This relates to a recovery time of 4 / 4.9152E6 or 813.8 nano seconds. The recovery time will shorten if the oscillator on an ACB is changed to a higher value (i.e. 20MHz recovery time = 200ns). When programming in a high level language such as C or C++, care must be taken to insure that loop delays are not optimized by the compiler. In most cases, a routine that contains several JMP $+2 statements encoded with in-line assembly is an efficient way to provide recovery time for the SCC. In the example below, note that sequential I/O accesses refer not only to selecting 85x30 registers, but also to any back to back accesses (read or write). Bad C Example: outp(SCCCONTROL, WR1); /* Select Write Register 1 */ delay(); /* Recovery time */ outp(SCCCONTROL, 0x00); /* Write to Write Register 1 */ /* ERROR: recovery time violated */ outp(SCCCONTROL, WR0); /* Select Write Register 0 */ delay(); /* Recovery time */ outp(SCCCONTROL, 0x00); /* Write to Write Register 0 */ Good C Example: outp(SCCCONTROL, WR1); /* Select Write Register 1 */ delay(); /* Recovery time */ outp(SCCCONTROL, 0x00); /* Write to Write Register 1 */ delay(); /* ERROR */ outp(SCCCONTROL, WR0); /* Select Write Register 0 */ delay(); /* Recovery time */ outp(SCCCONTROL, 0x00); /* Write to Write Register 0 */ All programmers interested in highly optimized code, may use JMP SHORT $+2 in place of JMP $+2. The JMP SHORT $+2 takes up 2 bytes of code space versus 3 bytes for JMP $+2.