Digital I/O "Bit Bang" Register - VersaLogic EBX-22 Reference Manual

Table of Contents

Advertisement

'MCP23S17 SPI Control Byte (Write)
'---------------------------------
'D7 SLAVEFA3
'D6 SLAVEFA2
'D5 SLAVEFA1
'D4 SLAVEFA0
'D3 SLAVEHA2
'D2 SLAVEHA1
'D1 SLAVEHA0
'D0 READWRITE = 0 Read/Write Bit = Write
OUT SPIDATA3, &H40
WHILE (INP(SPISTATUS) AND &H1) = &H1: WEND
'INITIALIZE DIRECTION OF DIO LINES D15-D8 AS INPUTS
'==================================================
'Direction = All Inputs
OUT SPIDATA1, &HFF
'MCP23S17 IODIRA Register Address
OUT SPIDATA2, &H0
'MCP23S17 SPI Control Byte (Write)
OUT SPIDATA3, &H40
WHILE (INP(SPISTATUS) AND &H1) = &H1: WEND
'Repeat until ESC key is pressed
WHILE INKEY$ <> CHR$(27)
'READ DIO INPUT DATA FROM MCP23S17
'---------------------------------
'MCP23S17 GPIOA Register Address
OUT SPIDATA2, &H12
'MCP23S17 SPI Control Byte (Read)
OUT SPIDATA3, &H41
WHILE (INP(SPISTATUS) AND &H1) = &H1: WEND
'DIO Input Data
PRINT HEX$(INP(SPIDATA1))
WEND
SYSTEM
D
I/O "B
IGITAL
IT
A special register is available at 1D6h, which enables the direct control ("bit banging") of digital
I/O. To use this register, the DIO field (bits D4-D3) of the MODCON register (1DFh) must be set
to 0h (see Table 44 for mode control settings).
DIOBB (Read/Write) 1D6h
D7
DIOIN
DIOINT
EBX-22 Reference Manual
= 0 Slave Address (Fixed Portion)
= 1
"
"
= 0
"
"
= 0
"
"
= 0 Slave Address Bits (Hardware Address Bits)
= 0
"
"
= 0
"
"
B
" R
ANG
EGISTER
D6
D5
D4
Reserved
Reserved
Table 29: DIOBB Register Bit Assignments
"
"
"
"
"
"
"
"
"
"
D3
D2
DIOCLK
DIOOUT
Interfaces and Connectors
D1
D0
DIOCS1
DIOCS0
59

Advertisement

Table of Contents
loading

Table of Contents