Operation
SPX-5 Reference Manual
11
Switch Control Code Example
The following code example shows how to configure the base board’s SPX registers for the SPX-
5 and turns on switch 3 (SPX-5 J3 pins 1 and 2). The test setup is configured with an appropriate
external voltage supply for the load driven and the SPX-5 jumpered for SS0#.
; Setup SPI configuration registers
MOV
DX, 0x1D9
MOV
AL, 0x20
;SPISTATUS: 4MHz, no IRQ, left-shift data
OUT
DX, AL
MOV
DX, 0x1D8
MOV
AL, 0x59
;SPICONTROL: SCLK idle low, falling edge,
OUT
DX, AL
;16bit frame, manual SS0# (asserted now)
; Output MC33879 switch command
MOV
DX, 0x1DC
MOV
AX, 0xFF04
;SPIDATA3: fault detect current ON (all),
OUT
DX, AX
;SPIDATA2: MOSFET switch 3 ON
CALL BUSY
;Poll BUSY flag to wait for SPI transaction
; Complete SPI transaction
MOV
DX, 0x1D8
MOV
AL, 0x58
;SPICONTROL: De-assert SS0#
OUT
DX, AL
; Read Fault Status Register contents
MOV
DX, 0x1DC
IN
AL, DX
;MC33879 fault status now in AL
; Wait loop for SPI transaction
BUSY: MOV
DX, 0x1D9
IN
AL, DX
;Read SPISTATUS
AND
AL, 0x01
;Isolate BUSY flag
JNZ
BUSY
;Loop if SPI transaction not complete