03.01.2015 Views

80C186EC/80C188EC Microprocessor User's Manual

80C186EC/80C188EC Microprocessor User's Manual

80C186EC/80C188EC Microprocessor User's Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

SERIAL COMMUNICATIONS UNIT<br />

3. If the Clear-to-Send feature is used, set the CEN bit to enable it.<br />

4. If receptions are desired, set the REN bit to enable the RX machine. Note the TX machine<br />

need not be explicitly enabled.<br />

At this point, you will be able to transmit and receive in the mode specified. Now that the serial<br />

port is operating, you must correctly interpret its status. This is done by reading the SxSTS register<br />

(Figure 11-14 on page 11-16) and interpreting its contents. Reading SxSTS clears all bits<br />

except the CTS and TXE bits. SxSTS must first be saved in memory and then each bit can be<br />

interpreted individually.<br />

The RI, TI and TXE bits indicate the condition of the transmit and receive buffers. RI and TI are<br />

also used with the Interrupt Control Unit for interrupt-based communications. The OE, FE and<br />

PE bits indicate any errors when a character is received. Once an error occurs, the appropriate bit<br />

remains set until SxSTS is read. For example, assume a character is received with a parity error<br />

(PE set) and a subsequent error-free character is received. If the SxSTS register was not read between<br />

the two receptions, the PE bit remains set.<br />

11.2.2.2 Modes 2 and 3 for Multiprocessor Communications<br />

Programming for multiprocessor communications is much the same as the stand-alone operation.<br />

The only added complexity is that the ninth data bit must be controlled and interpreted correctly.<br />

The ninth data bit is set for transmissions by setting the TB8 bit in SxCON. TB8 is cleared after<br />

every transmission. TB8 is not double-buffered. This is usually not a problem, as very few bytes<br />

are actually transmitted with TB8 equal to one. When writing TB8, make sure that the other bits<br />

in SxCON are written with their appropriate value.<br />

In Modes 2 and 3, the state of the ninth data bit can be determined by the RB8 bit in SxSTS. RB8<br />

reflects the ninth bit for the character currently in SxRBUF. Note that the RB8 bit shares functionality<br />

with the PE bit in SxSTS. When parity is enabled, the PE bit has precedence over RB8.<br />

11.2.2.3 Sending and Receiving a Break Character<br />

The serial port can send as well as receive BREAK characters. A BREAK character is a long<br />

string of zeros. To send a BREAK character, set the SBRK bit in SxCON. SBRK drives the TXD<br />

pin immediately low, regardless of the current serial port mode. The user controls the length of<br />

the BREAK character in software by controlling the length of time that SBRK remains set. When<br />

writing SBRK, make sure the other bits in SxCON retain their current states.<br />

11-14

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!