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

8XC196Kx, Jx, CA USER’S MANUAL

9.5.2Enabling the Slave Port Interrupts

The master can generate three interrupt requests: command buffer full (CBF), output buffer empty (OBE), and input buffer full (IBF). The CBF interrupt is used in standard slave mode; the OBE and IBF interrupts are used in shared memory mode. To enable an interrupt, set the corresponding bit in the interrupt mask register (Table 9-2 on page 9-4).

9.6DETERMINING SLAVE PORT STATUS

The master can determine the status of the slave port by reading the SLP_STAT register (Figure 9-7). It can also read the interrupt pending registers (Table 9-2 on page 9-4) to determine the status of the interrupts.

9.7USING STATUS BITS TO SYNCHRONIZE MASTER AND SLAVE

The status bits in the SLP_STAT register can be used to synchronize the master with the slave. Because synchronization of the status bits is not monitored by the status flags, it is more difficult for the master to monitor. Software must ensure data integrity throughout the operation. Two techniques are recommended — a double read or a software flag.

If the master processor is fast enough to read SLP_STAT twice before the contents change, the master can compare the readings from before and after the data fetch. If the readings are identical, the data is guaranteed correct.

In standard slave mode, the slave can use bit 7 of SLP_STAT to indicate valid data. To update the status, the slave performs the following sequence:

Clear the flag bit (bit 7) without changing the other four status bits.

Update the status bits (SLP_STAT.6:3).

Set the flag bit (bit 7) without changing the other four status bits.

9-16

SLAVE PORT

SLP_STAT

Address:

1FF8H

(8XC196Kx)

Reset State:

00H

The master can read the slave port status (SLP_STAT) register to determine the status of the slave. The slave can read all bits and can write bits 3–7 for general-purpose status information. (The bits are user-defined flags.) If the master attempts to write to SLP_STAT, it actually writes to SLP_CMD. To read from this register (rather than P3_REG), the master must first write “1” to the pin selected by SLP_CON.2.

 

7

 

 

 

 

 

 

 

 

 

 

0

KQ, KR

 

SF4

SF3

 

SF2

SF1

 

SF0

 

CBE

IBE

 

OBF

 

 

7

 

 

 

 

 

 

 

 

 

 

0

KS, KT

 

 

 

 

 

 

 

 

 

 

 

 

 

 

SMO/SF4

SF3

 

SF2

SF1

 

SF0

 

CBE

IBE

 

OBF

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bit

 

Bit

 

 

 

 

Function

 

 

 

 

Number

Mnemonic

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

7(KS, KT)

SMO/SF4

Shared Memory Operation/Status Field Bit 4

 

 

 

 

 

 

 

In shared memory mode bit 7 (SMO) indicates whether the bus

 

 

 

 

interface logic received a read (1) or a write (0). SMO can be read but

 

 

 

not written.

 

 

 

 

 

 

 

 

 

 

 

 

In standard slave mode bit 7 (SF4) is the high bit of the status field.

 

 

 

 

 

 

 

 

 

 

 

 

7:3 (KQ, KR)

SF4:0

Status Field

 

 

 

 

 

 

 

 

 

6:3 (KS, KT)

SF3:0

The slave can write to these bits for general-purpose status infor-

 

 

 

 

 

 

mation. (The bits are user-defined flags).

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2

CBE

Command Buffer Empty

 

 

 

 

 

 

 

 

 

 

This flag is set after the slave reads SLP_CMD. The flag is cleared and

 

 

 

the command buffer full (CBF) interrupt pending bit (INT_PEND1.0) is

 

 

 

set after the master writes to SLP_CMD.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1

IBE

Input Buffer Empty

 

 

 

 

 

 

 

 

 

 

 

This flag is set after the slave reads P3_PIN. The flag is cleared and

 

 

 

the IBF interrupt pending bit (INT_PEND.7) is set after the master

 

 

 

writes to P3_PIN.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

OBF

Output Buffer Full

 

 

 

 

 

 

 

 

 

 

 

This flag is set after the slave writes to P3_REG. The flag is cleared

 

 

 

and the OBE interrupt pending bit (INT_PEND.6) is set after the master

 

 

 

reads P3_REG.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

On the 8XC196KQ, KR devices this bit functions only as SF4.

Figure 9-7. Slave Port Status (SLP_STAT) Register

9-17

10

Event Processor

Array (EPA)

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