Digital I/O Port Configuration Using The Spi Interface - VersaLogic Copperhead VL-EBX-41 Reference Manual

Intel 3rd generation core quad or dual core sbc with ethernet, hd graphics, acpi 4.0, sata, raid, usb, eusb, msata, sumit, hd audio, serial, analog + digital i/o, and spx
Table of Contents

Advertisement

D
I/O P
IGITAL
ORT
Digital I/O channels 0-31 are accessed via SPI slave select 6 (writing 6h to the SS field in
SPICONTROL). Each pair of I/O ports is configured by a set of paged I/O registers accessible
through SPI. These registers control settings such as signal direction, input polarity, and interrupt
source.
Digital I/O Initialization Using the SPI Interface
There are two Microchip MCP23S17 digital I/O devices used. Digital I/O channels 0-15 map to
device #0 (address "000") and channels 15-31 to device #1 (address "001"). Please refer to the
Microchip MCP23S17 datasheet
the digital I/O devices a '1' must be written to the control bit HAEN in the IOCON register
(write a 8h to this register) in the MCP23S17 devices. This write is done to device address "000"
which will actually write this HAEN bit to both devices. Once this HAEN bit is set then both
devices can be independently accessed. This must be done anytime these parts are reset. Example
code is shown below (this assumes the FPGA base address is the default setting CA0h).
MOV
MOV
OUT
MOV
MOV
OUT
MOV
MOV
OUT
MOV
MOV
OUT
MOV
MOV
OUT
BUSY: MOV
IN
AND
JNZ
Digital I/O Interrupt Generation Using the SPI Interface
Digital I/O can be configured to issue hardware interrupts on the transition (high to low or low to
high) of any digital I/O pin. IRQ assignment is made in SPI control register SPISTATUS. This
IRQ is shared among all SPI devices connected to the VL-EBX-41 (the ADC and DAC devices
on the SPI interface do not have interrupts). Digital I/O chip interrupt configuration is achieved
through I/O port register settings. Please refer to the
information.
The on-board digital I/O chips must be configured for open-drain and mirrored interrupts in order
for any SPI device to use hardware interrupts. The following code example illustrates how to do
this for device #0 on channels 0-15. Normally, the BIOS initializes the on-board digital I/O chips
at boot time.
MOV
MOV
OUT
EBX-41 Reference Manual
C
U
ONFIGURATION
SING THE
for more information about the MCP23S17. Before accessing
DX, CA8h
AL, 26h
;SPICONTROL: SPI Mode 00, 24bit, auto, SPI 6
DX, AL
DX, CA9h
AL, 30h
;SPISTATUS: 8MHz, no IRQ, left-shift
DX, AL
DX, CABh
AL, 08h
;SPIDATA1: Set HAEN Bit to a '1'
DX, AL
DX, CACh
AL, 0Ah
;SPIDATA2: MCP23S17 IOCON addr 0x0A
DX, AL
DX, CADh
AL, 40h
;SPIDATA3: MCP23S17 write to device "000"
DX, AL
DX, CA9h
AL, DX
;Get SPI status
AL, 01h
;Isolate the BUSY bit
BUSY
;Loop back if SPI transaction is not complete
DX, CA8h
AL, 26h
;SPICONTROL: SPI Mode 00, 24bit, auto SPI 6
DX, AL
SPI I
NTERFACE
Microchip MCP23S17 datasheet
Interfaces and Connectors
for more
41

Advertisement

Table of Contents
loading

Table of Contents