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

8XC196Kx, Jx, CA USER’S MANUAL

7.3.2.5Multiprocessor Communications

Modes 2 and 3 are provided for multiprocessor communications. In mode 2, the serial port sets the RI interrupt pending bit only when the ninth data bit is set. In mode 3, the serial port sets the RI interrupt pending bit regardless of the value of the ninth bit. The ninth bit is always set in address frames and always cleared in data frames.

One way to use these modes for multiprocessor communication is to set the master processor to mode 3 and the slave processors to mode 2. When the master processor wants to transmit a block of data to one of several slaves, it sends out an address frame that identifies the target slave. Because the ninth bit is set, an address frame interrupts all slaves. Each slave examines the address byte to check whether it is being addressed. The addressed slave switches to mode 3 to receive the data frames, while the slaves that are not addressed remain in mode 2 and are not interrupted.

7.4PROGRAMMING THE SERIAL PORT

To use the SIO port, you must configure the port pins to serve as special-function signals and set up the SIO channel.

7.4.1Configuring the Serial Port Pins

Before you can use the serial port, you must configure the associated port pins to serve as specialfunction signals. Table 7-1 on page 7-2 lists the pins associated with the serial port. Table 7-2 lists the port configuration registers, and Chapter 6, “I/O Ports,” explains how to configure the pins.

7.4.2Programming the Control Register

The SP_CON register (Figure 7-6) selects the communication mode and enables or disables the receiver, parity checking, and nine-bit data transmissions. Selecting a new mode resets the serial I/O port and aborts any transmission or reception in progress on the channel.

7-8

SERIAL I/O (SIO) PORT

SP_CON

Address:

1FBBH

 

Reset State:

00H

The serial port control (SP_CON) register selects the communications mode and enables or disables the receiver, parity checking, and nine-bit data transmission.

 

7

 

 

 

 

 

 

 

 

 

 

 

 

0

CA, Jx, KQ, KR

 

 

 

TB8

 

REN

 

PEN

M1

 

M0

 

 

7

 

 

 

 

 

 

 

 

 

 

 

 

0

KS, KT

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PAR

 

TB8

 

REN

 

PEN

M1

 

M0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bit

 

Bit

 

 

 

 

 

Function

 

 

 

 

Number

Mnemonic

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

7:6

 

Reserved; always write as zeros.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

5

PAR

 

Parity Selection Bit

 

 

 

 

 

 

 

 

 

 

 

Selects even or odd parity.

 

 

 

 

 

 

 

 

 

 

 

1 = odd parity

 

 

 

 

 

 

 

 

 

 

 

 

 

0 = even parity

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4

TB8

 

Transmit Ninth Data Bit

 

 

 

 

 

 

 

 

 

 

 

This is the ninth data bit that will be transmitted in mode 2 or 3. This bit

 

 

 

 

is cleared after each transmission, so it must be set before SBUF_TX is

 

 

 

 

written. When SP_CON.2 is set, this bit takes on the even parity value.

 

 

 

 

 

 

 

 

 

 

 

 

 

3

REN

 

Receive Enable

 

 

 

 

 

 

 

 

 

 

 

 

 

Setting this bit enables the receiver function of the RXD pin. When this

 

 

 

 

bit is set, a high-to-low transition on the pin starts a reception in mode 1,

 

 

 

 

2, or 3. In mode 0, this bit must be clear for transmission to begin and

 

 

 

 

must be set for reception to begin. Clearing this bit stops a reception in

 

 

 

 

progress and inhibits further receptions.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2

PEN

 

Parity Enable

 

 

 

 

 

 

 

 

 

 

 

 

 

In modes 1 and 3, setting this bit enables the parity function. This bit

 

 

 

 

must be cleared if mode 2 is used. When this bit is set, TB8 takes the

 

 

 

 

parity value on transmissions. With parity enabled, SP_STATUS.7

 

 

 

 

 

becomes the receive parity error bit.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1:0

M1:0

 

Mode Selection

 

 

 

 

 

 

 

 

 

 

 

 

 

These bits select the communications mode.

 

 

 

 

 

 

 

 

M1

M0

 

 

 

 

 

 

 

 

 

 

 

 

 

0

0

 

mode 0

 

 

 

 

 

 

 

 

 

 

 

0

1

 

mode 1

 

 

 

 

 

 

 

 

 

 

 

1

0

 

mode 2

 

 

 

 

 

 

 

 

 

 

 

1

1

 

mode 3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

This bit is reserved on the 87C196CA, 8XC196Jx, KQ, KR devices. For compatibility with future devices, write zero to this bit.

Figure 7-6. Serial Port Control (SP_CON) Register

7-9

8XC196Kx, Jx, CA USER’S MANUAL

7.4.3Programming the Baud Rate and Clock Source

The SP_BAUD register (Figure 7-7) selects the clock input for the baud-rate generator and defines the baud rate for all serial I/O modes. This register acts as a control register during write operations and as a down-counter monitor during read operations.

WARNING

Writing to the SP_BAUD register during a reception or transmission can corrupt the received or transmitted data. Before writing to SP_BAUD, check the SP_STATUS register to ensure that the reception or transmission is complete.

SP_BAUD

Address:

1FBCH

 

Reset State:

0000H

The serial port baud rate (SP_BAUD) register selects the serial port baud rate and clock source. The most-significant bit selects the clock source. The lower 15 bits represent BAUD_VALUE, an unsigned integer that determines the baud rate.

The maximum BAUD_VALUE is 32,767 (7FFFH). In asynchronous modes 1, 2, and 3, the minimum BAUD_VALUE is 0000H when using XTAL1 and 0001H when using T1CLK. In synchronous mode 0, the minimum BAUD_VALUE is 0001H for transmissions and 0002H for receptions.

 

15

 

 

 

 

 

 

 

8

CA, Jx

 

BV14

BV13

BV12

 

BV11

BV10

BV9

BV8

 

 

7

 

 

 

 

 

 

 

0

 

 

 

 

 

 

 

 

 

 

 

 

 

BV7

BV6

BV5

BV4

 

BV3

BV2

BV1

BV0

 

 

15

 

 

 

 

 

 

 

8

Kx

 

 

 

 

 

 

 

 

 

 

 

CLKSRC

BV14

BV13

BV12

 

BV11

BV10

BV9

BV8

 

 

7

 

 

 

 

 

 

 

0

 

 

 

 

 

 

 

 

 

 

 

 

 

BV7

BV6

BV5

BV4

 

BV3

BV2

BV1

BV0

 

 

 

 

 

 

 

 

 

 

 

Bit

 

Bit

 

 

 

 

Function

 

 

 

Number

Mnemonic

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

15

CLKSRC

Serial Port Clock Source

 

 

 

 

 

 

 

 

This bit determines whether the serial port is clocked from an internal or

 

 

 

an external source.

 

 

 

 

 

 

 

 

 

1 = XTAL1 (internal source)

 

 

 

 

 

 

 

 

0 = T1CLK (external source)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

On the 87C196CA, 8XC196Jx devices the T1CLK pin is not implemented; therefore, on these devices this bit is reserved and should be written as one.

Figure 7-7. Serial Port Baud Rate (SP_BAUD) Register

7-10

SERIAL I/O (SIO) PORT

SP_BAUD (Continued)

Address:

1FBCH

 

Reset State:

0000H

The serial port baud rate (SP_BAUD) register selects the serial port baud rate and clock source. The most-significant bit selects the clock source. The lower 15 bits represent BAUD_VALUE, an unsigned integer that determines the baud rate.

The maximum BAUD_VALUE is 32,767 (7FFFH). In asynchronous modes 1, 2, and 3, the minimum BAUD_VALUE is 0000H when using XTAL1 and 0001H when using T1CLK. In synchronous mode 0, the minimum BAUD_VALUE is 0001H for transmissions and 0002H for receptions.

 

15

 

 

 

 

 

 

 

 

 

 

 

 

 

 

8

CA, Jx

 

BV14

 

BV13

 

 

BV12

 

 

 

BV11

 

BV10

 

BV9

BV8

 

 

7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

BV7

BV6

 

BV5

 

 

BV4

 

 

 

BV3

 

BV2

 

BV1

BV0

 

 

15

 

 

 

 

 

 

 

 

 

 

 

 

 

 

8

Kx

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

CLKSRC

BV14

 

BV13

 

 

BV12

 

 

 

BV11

 

BV10

 

BV9

BV8

 

 

7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

BV7

BV6

 

BV5

 

 

BV4

 

 

 

BV3

 

BV2

 

BV1

BV0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bit

 

Bit

 

 

 

 

 

 

 

 

Function

 

 

 

Number

Mnemonic

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

14:0

BV14:0

These bits constitute the BAUD_VALUE.

 

 

 

 

 

 

 

 

Use the following equations to determine the BAUD_VALUE for a given

 

 

 

baud rate.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Synchronous mode 0:††

 

 

 

 

 

 

 

 

 

BAUD_VALUE =

 

 

FOSC

1

 

T1CLK

 

 

 

 

Baud---- Rate × 2---------------------------------

or ---------------------------

 

 

 

 

 

 

 

 

 

 

 

Baud Rate

 

 

 

 

Asynchronous modes 1, 2, and 3:

 

 

 

 

 

 

 

 

 

BAUD_VALUE =

 

 

FOSC

1

or

T1CLK

 

 

 

 

----

-

--------------------------

-

--

------

 

 

 

 

 

 

 

 

 

Baud Rate × 16

 

Baud Rate × 8

 

 

 

 

†† For mode 0 receptions, the BAUD_VALUE must be 0002H or greater.

 

 

 

Otherwise, the resulting data in the receive shift register will be incorrect.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

On the 87C196CA, 8XC196Jx devices the T1CLK pin is not implemented; therefore, on these devices this bit is reserved and should be written as one.

Figure 7-7. Serial Port Baud Rate (SP_BAUD) Register (Continued)

7-11

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