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

8XC196Kx, Jx, CA USER’S MANUAL

 

 

 

 

 

 

SCx

1

2

3

4

5

6

7

8

 

 

 

 

 

 

 

 

STE

 

 

 

 

 

 

 

 

SDx (out)

MSB

D6

D5

D4

D3

D2

D1

D0

SDx (in)

valid

valid

valid

valid

valid

valid

valid

valid

SCx

1

2

3

4

5

6

7

8

(Handshake Mode)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Slave Receiver Pulls SCx low

 

 

 

 

 

 

 

 

A0266-01

 

Figure 8-3. SSIO Transmit/Receive Timings

 

 

8.4SSIO HANDSHAKING

Handshaking (Figure 8-4) prevents a data underflow or overflow from occurring at the slave, which enables a master device to perform SSIO data transfers using the PTS. Without handshaking, data overflows and underflows would make it nearly impossible to use the PTS for transferring blocks of data. Handshaking takes place in hardware, using the clock pins, with no CPU overhead. When the master is the transmitter and the slave is the receiver, the slave pulls the clock line low until it is ready to receive a byte. This prevents a data overflow at the slave. In the opposite configuration, the slave pulls the clock line low until its buffer is loaded with data. This prevents a data underflow at the slave.

8.4.1SSIO Handshaking Configuration

To use the PTS with the SSIO in handshaking mode, the SSIO channels must be configured as follows:

Channels must be auto-enabled (both the ATR and STE bits in SSIOx_CON must be set).

Handshaking mode must be selected (the THS bit in SSIOx_CON must be set).

The clock pin, SCx, must be configured as a special-function, open-drain output in both master and slave. (This requires an external pull-up resistor.)

8-6

SYNCHRONOUS SERIAL I/O (SSIO) PORT

Load SSIOx_BUF

SCx Pin High

No ?

Yes

Transmit Byte

Set SSIOx Interrupt

Pending Bit

SSIO Transmit Handshaking

Receive Byte

Pull SC Pin Low

SSIOx_BUF No Read

?

Yes

Float SCx Pin

SSIO Receive Handshaking

A0232-03

Figure 8-4. SSIO Handshaking Flow Diagram

8.4.2SSIO Handshaking Operation

When handshaking is enabled, the slave pulls its clock input (SCx) low whenever it is busy. (In receive mode, the slave is busy when the buffer is full; in transmit mode, the slave is busy when the buffer is empty.) This happens automatically one to two state times after the rising clock edge corresponding to the last data bit of the transmitted 8-bit packet. The slave releases its SCx line only after the CPU reads from or writes to SSIOx_BUF, which clears the transmit buffer status (TBS) bit in SSIOx_CON and indicates that SSIOx_BUF is available for another packet to be received or transmitted.

When handshaking is enabled, the master leaves its clock output (SCx) high at the end of each byte transfer. This allows the slave to pull the clock line low if its SSIOx_BUF register is unavailable for the next transfer. The master waits for the clock line to return high before it attempts the next transfer. (If handshaking is not enabled for the master, the master drives the clock line low between transfers.)

8-7

8XC196Kx, Jx, CA USER’S MANUAL

The following example describes how the master can transmit 16 bytes of data to the slave through the PTS, using this optional handshaking capability.

1.These four steps can occur in any order:

— You initialize the master as a transmitter and the slave as a receiver.

— The master prepares 16 bytes for transm ission and places them in RAM.

— The master initializes a PTS channel to move data from RAM to SSIO x_BUF.

— The slave initializes a PTS channel to move data from SSIO x_BUF to RAM.

2.You set the master’s SSIO x interrupt pending bit in the INT_PEND1 register.

3.The PTS transfers a byte to SSIOx_BUF.

4.The slave pulls the clock line low until it is ready to receive a byte, then allows the clock line to float (allowing the external resistor to pull it up).

5.The master detects the high clock line and transmits the byte.

6.When the master finishes transmitting the byte, it sets its SSIOx interrupt pending bit in INT_PEND1 and allows the clock line to float.

7.When the slave finishes receiving the byte, it sets its SSIOx interrupt pending bit in INT_PEND1.

8.Steps 3 through 7 are repeated until the PTS byte count reaches 0.

9.The next interrupt requests PTS service.

8-8

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