Slave Device Program - Intel 8XC196K Series User Manual

Table of Contents

Advertisement

The master first reads the P3_REG register. This ensures that the slave's P3_REG is indeed emp-
ty, clears the OBF flag, and pulls SLPINT low. Next, it loads the address it wants to read into the
SLP_CMD register. This causes a CBF interrupt in the slave processor. The slave reads that lo-
cation and stores the data in P3_REG, which sets the OBF flag and forces SLPINT high. This
notifies the master to read the P3_REG register.
9.4.1.2

Slave Device Program

Once the slave port and ports 3 and 5 are initialized, the slave device program is strictly interrupt
driven. When the slave device receives a byte in the SLP_CMD register, the command buffer full
(CBF) interrupt is generated. The CBF interrupt service routine reads the OBF and IBE flags in
the SLP_STAT register to determine whether the master device is sending data or requesting a
data read. For a data-read request, the master device clears P3_REG, which clears the OBF flag,
before it loads SLP_CMD. For a data write, the master writes P3_PIN, which clears the IBE flag,
before it loads SLP_CMD. Therefore, only one of the two flags is clear when the CBF interrupt
service routine is entered.
If the IBE flag is clear (the input buffer, P3_PIN, is full), the slave moves the data from the
P3_PIN register to the specified address. If the OBF flag is clear (the output buffer, P3_REG, is
empty), the slave moves the data from the specified address to the P3_REG register so that the
master can read it.
The following code segment shows the CBF interrupt service routine. The CBF interrupt must be
enabled and interrupts must be globally enabled for this routine to function.
CBF_ISR:
PUSHA
LDBZE MAILBOX, SLP_CMD[0]
ADDB MAILBOX+1, BASE
LDB
TEMPW, SLP_STAT[0]
BBC
TEMPW, 1, WRITE_DATA
BBC
TEMPW, 0, READ_DATA
DONE_ISR:
POPA
RET
WRITE_DATA:
LDB
TEMPW, P3_PIN[0]
STB
TEMPW, [MAILBOX]
POPA
RET
; read SLP_CMD value (mailbox=address)
; window address is 400-4FFH
; get SLP_STAT register
; if IBE=0, master wants to write
; if OBF=0, master wants to read
; if neither IBE=0 nor OBF=0, RETURN
; if both are set, an error has occurred
; no read or write can be performed
; (BBC is an assembler command that is
; translated to either a JBC, SJMP, or LJMP,
; depending upon the distance to the
; referenced address.)
; get data to write
; write P3_PIN at SLP_CMD+400H
SLAVE PORT
9-9

Advertisement

Table of Contents
loading

Table of Contents