Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
8XC196Kx,8XC196Jx,87C196CA microcontroller family user's manual.1995.pdf
Скачиваний:
57
Добавлен:
23.08.2013
Размер:
3.97 Mб
Скачать

8XC196Kx, Jx, CA USER’S MANUAL

Table 7-2. Serial Port Control and Status Registers (Continued)

Mnemonic

Address

Description

SP_BAUD

1FBCH,1FBDH

Serial Port Baud Rate

 

 

This register selects the serial port baud rate and clock source. The

 

 

most-significant bit selects the clock source. The lower 15 bits

 

 

represent the BAUD_VALUE, an unsigned integer that determines

 

 

the baud rate.

 

 

 

SP_CON

1FBBH

Serial Port Control

 

 

This register selects the communications mode and enables or

 

 

disables the receiver, parity checking, and ninth-bit data transmis-

 

 

sions. The TB8 bit is cleared after each transmission.

 

 

 

SP_STATUS

1FB9H

Serial Port Status

 

 

This register contains the serial port status bits. It has status bits for

 

 

receive overrun errors (OE), transmit buffer empty (TXE), framing

 

 

errors (FE), transmit interrupt (TI), receive interrupt (RI), and

 

 

received parity error (RPE) or received bit 8 (RB8). Reading

 

 

SP_STATUS clears all bits except TXE; writing a byte to SBUF_TX

 

 

clears the TXE bit.

 

 

 

Except as otherwise noted, write zeros to the reserved bits in these registers.

††The T1CLK pin is not implemented on the 8XC196CA, JQ, JR, JT, JV devices. XTAL1 must provide the serial port clock.

7.3SERIAL PORT MODES

The serial port has both synchronous and asynchronous operating modes for transmission and reception. This section describes the operation of each mode.

7.3.1Synchronous Mode (Mode 0)

The most common use of mode 0, the synchronous mode, is to expand the I/O capability of the device with shift registers (see Figure 7-2). In this mode, the TXD pin outputs a set of eight clock pulses, while the RXD pin either transmits or receives data. Data is transferred eight bits at a time with the least-significant bit first. Figure 7-3 shows a diagram of the relative timing of these signals. Note that only mode 0 uses RXD as an open-drain output.

In mode 0, RXD must be enabled for receptions and disabled for transmissions. (See “Programming the Control Register” on page 7-8.) When RXD is enabled, either a rising edge on the RXD input or clearing the receive interrupt (RI) flag in SP_STATUS starts a reception. When RXD is disabled, writing to SBUF_TX starts a transmission.

Disabling RXD stops a reception in progress and inhibits further receptions. To avoid a partial or undesired complete reception, disable RXD before clearing the RI flag in SP_STATUS. This can be handled in an interrupt environment by using software flags or in straight-line code by using the interrupt pending register to signal the completion of a reception.

7-4

SERIAL I/O (SIO) PORT

During a reception, the RI flag in SP_STATUS is set after the stop bit is sampled. The RI pending bit in the interrupt pending register is set immediately before the RI flag is set. During a transmission, the TI flag is set immediately after the end of the last (eighth) data bit is transmitted. TheTI pending bit in the interrupt pending register is generated when the TI flag in SP_STATUS is set.

Clock Inhibit

 

 

Shift / LOAD#

 

 

 

Px.x

Serial In

 

 

VCC

 

 

 

74HC05

 

 

 

15KΩ

 

 

 

Data

 

Shift Register

Q#

RXD

 

 

 

 

Clock

 

74HC165

 

 

 

TXD

 

 

 

 

Inputs

 

8XC196

 

 

 

VCC

Outputs

 

Device

 

 

Serial

 

 

 

In B

 

 

Serial In A

 

Shift Register

 

Clock

Clear

74HC164

 

 

 

 

Enable#

 

 

 

Px.x

 

 

 

A0264-02

Figure 7-2. Typical Shift Register Circuit for Mode 0

TXD

 

 

 

 

 

 

 

 

RXD (OUT)

D0

D1

D2

D3

D4

D5

D6

D7

RXD (IN)

D0

D1

D2

D3

D4

D5

D6

D7

Expanded:

 

 

 

 

 

 

 

 

XTAL1

 

 

 

 

 

 

 

 

TXD

 

 

 

 

 

 

 

 

RXD (OUT)

 

D0

 

D1

 

 

 

D2

RXD (IN)

 

D0

 

 

D1

 

 

 

 

 

 

 

 

 

 

 

A0109-02

 

 

Figure 7-3. Mode 0 Timing

 

 

 

7-5

Соседние файлы в предмете Электротехника