Slave Device Program - Intel 8XC196NT User Manual

Table of Contents

Advertisement

8XC196NT USER'S MANUAL
9.4.2.2

Slave Device Program

This example shows how the slave device reacts to reads and writes requested by the master. Re-
gardless of the operation to be performed, the address is latched into the SLP_CMD register. The
interrupt determines whether a read or write operation is to be performed.
An IBF interrupt requires a write operation. The slave branches to the IBF interrupt service rou-
tine, reads the data in the P3_PIN register, and writes that data to the address specified by adding
a base address to the value in SLP_CMD. When the slave reads P3_PIN, it forces SLPINT high,
which notifies the master that another operation can be performed.
An OBE interrupt requires a read operation. The slave branches to the OBE interrupt service rou-
tine, reads the data at the address specified by adding a base address to the value in SLP_CMD,
and writes that data into the P3_REG register. When the slave writes the P3_REG register, it forc-
es SLPINT high, which notifies the master that another operation can be performed. (Remember
that read operations are pipelined.)
The following code segment shows the IBF and OBE interrupt service routines. The interrupt ser-
vice routines are very much alike. One reads from the SFR space to the memory block; the other
reads from the memory block to the SFR space. The slave need only know which routine to exe-
cute. The IBF and OBE interrupts must be enabled and interrupts must be globally enabled for
these routines to function.
IBF_ISR:
PUSHA
LDBZE ADDR, SLP_CMD[0]
ADDB ADDR+1, BASE
LDB
TEMP, P3_PIN[0]
STB
TEMP, [ADDR]
POPA
RET
OBE_ISR:
PUSHA
LDBZE ADDR, SLP_CMD[0]
ADDB ADDR+1, BASE
LDB
TEMP, [ADDR]
STB
TEMP, P3_REG[0]
POPA
RET
9-12
; save flags
; load SLP_CMD value into Addr register
; add a base to address (16-bit address)
; read P3_PIN (read forces SLPINT high)
; write data to address
; save flags
; load SLP_CMD value into Addr register
; add a base to address (16-bit address)
; load data from address to temp register
; write data to P3_REG
; (write forces SLPINT high)

Advertisement

Table of Contents
loading

Table of Contents