12.07.2015 Views

80C186EB/80C188EB Microprocessor User's Manual - CEUNES

80C186EB/80C188EB Microprocessor User's Manual - CEUNES

80C186EB/80C188EB Microprocessor User's Manual - CEUNES

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

SERIAL COMMUNICATIONS UNIT3. If the Clear-to-Send feature is used, set the CEN bit to enable it.4. If receptions are desired, set the REN bit to enable the RX machine. Note the TX machineneed not be explicitly enabled.At this point, you will be able to transmit and receive in the mode specified. Now that the serialport is operating, you must correctly interpret its status. This is done by reading the SxSTS register(Figure 10-14 on page 10-16) and interpreting its contents. Reading SxSTS clears all bitsexcept the CTS and TXE bits. SxSTS must first be saved in memory and then each bit can beinterpreted individually.The RI, TI and TXE bits indicate the condition of the transmit and receive buffers. RI and TI arealso used with the Interrupt Control Unit for interrupt-based communications. The OE, FE andPE bits indicate any errors when a character is received. Once an error occurs, the appropriate bitremains set until SxSTS is read. For example, assume a character is received with a parity error(PE set) and a subsequent error-free character is received. If the SxSTS register was not read betweenthe two receptions, the PE bit remains set.10.2.2.2 Modes 2 and 3 for Multiprocessor CommunicationsProgramming for multiprocessor communications is much the same as the stand-alone operation.The only added complexity is that the ninth data bit must be controlled and interpreted correctly.The ninth data bit is set for transmissions by setting the TB8 bit in SxCON. TB8 is cleared afterevery transmission. TB8 is not double-buffered. This is usually not a problem, as very few bytesare actually transmitted with TB8 equal to one. When writing TB8, make sure that the other bitsin SxCON are written with their appropriate value.In Modes 2 and 3, the state of the ninth data bit can be determined by the RB8 bit in SxSTS. RB8reflects the ninth bit for the character currently in SxRBUF. Note that the RB8 bit shares functionalitywith the PE bit in SxSTS. When parity is enabled, the PE bit has precedence over RB8.10.2.2.3 Sending and Receiving a Break CharacterThe serial port can send as well as receive BREAK characters. A BREAK character is a longstring of zeros. To send a BREAK character, set the SBRK bit in SxCON. SBRK drives the TXDpin immediately low, regardless of the current serial port mode. The user controls the length ofthe BREAK character in software by controlling the length of time that SBRK remains set. Whenwriting SBRK, make sure the other bits in SxCON retain their current states.10-14

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

Saved successfully!

Ooh no, something went wrong!