Digital I/O
SPX Reference Manual
10
MOV
AL, 00h
;SPIDATA2: MCP23S17 register address 00h
OUT
DX,
AL
MOV
DX,
1DDh
MOV
AL, 40h
;SPIDATA3: MCP23S17 write command
OUT
DX,
AL
CALL
BUSY
;Poll busy flag to wait for SPI transaction
;Write 55h to MCP23S17 register GPIOA
MOV
DX,
1DBh
MOV
AL, 55h
;SPIDATA1: data to write
OUT
DX,
AL
MOV
DX,
1DCh
MOV
AL, 14h
;SPIDATA2: MCP23S17 register address 14h
OUT
DX,
AL
MOV
DX,
1DDh
MOV
AL, 40h
;SPIDATA3: MCP23S17 write command
OUT
DX,
AL
CALL
BUSY
;Poll busy flag to wait for SPI transaction
BUSY: MOV
DX, 1D9h
IN
AL,
DX
;Get
SPISTATUS
AND
AL, 01h
;Isolate the BUSY flag
JNZ
BUSY
;Loop if SPI transaction not complete