Interfaces and Connectors
EBX-11 Reference manual
50
A
NALOG
I
NPUT
C
ODE
E
XAMPLE
The following code example illustrates the procedure for reading an analog voltage from the
onboard ADC channel 3. A 32bit SPI frame is used to provide a valid single sample.
MOV
DX, 1D8h
MOV
AL, 35h
;SPICONTROL: SPI Mode 00, 32bit, auto ADC_SS#
OUT
DX, AL
MOV
DX, 1D9h
MOV
AL, 30h
;SPISTATUS: 8MHz, no IRQ, left-shift
OUT
DX, AL
;SPIDATA2, SPIDATA1, SPIDATA0: don’t care
MOV
DX, 1DDh
MOV
AL, 18h
;SPIDATA3: ADC78H90 AIN4 = EBX-11 ADCH3
OUT
DX, AL
BUSY: MOV DX, 1D9h
;Get SPISTATUS
IN
AL, DX
AND
AL, 01h
;Isolate the BUSY bit
JNZ
BUSY
;Loop back if SPI transaction not complete
MOV
DX, 1DAh
;Point to SPIDATA0 register
IN
AX, DX
;16bit input reads current conversion data
;from SPIDATA1 into AH and from SPIDATA0 into
;AL
For more detailed information on the EBX-11 A/D converter, please refer to the
Semiconductor ADC78H90 Datasheet
StockCheck.com