Initiating An Analog Conversion; Analog Input Range - VersaLogic Python EBX-11 Reference Manual

Amd lx 800 based sbc with ethernet, video, audio, industrial i/o, and spi
Table of Contents

Advertisement

I
A
NITIATING AN
NALOG
The following procedure can be used to initiate an analog conversion.
1. Write 15h to the SPICONTROL register (I/O address 1D8h) – This value configures the
SPI port to select the on-board A/D converter, 16-bit frame length, low SCLK idle state,
rising edge SCLK edge, and automatic slave select.
2. Write 30h to the SPISTATUS register (I/O address 1D9h) – This value selects 8 MHz
SCLK speed, hardware IRQ disable, and left-shift data.
3. Write any value to SPIDATA2 (I/O address 1DCh) – This data will be ignored by the
A/D converter.
Write the analog input channel number to bits 5-3 of SPIDATA3 (1DDh) – Any write
4.
operation to this register triggers an SPI transaction.
Poll the BUSY bit until the conversion is completed.
5.
Read the conversion data from SPIDATA2 (lower 8 bits) and SPIDATA3 (upper 4 bits).
6.
Each analog conversion returns the conversion data from the previous conversion. The first
analog conversion after power-up or reset returns the data from ADCH0. The second conversion
returns the conversion data from the channel addressed in the first conversion. Each successive
conversion returns conversion data from the previous conversion.
This means that multiple conversions on the same A/D channel return valid data after every
conversion, starting with the second conversion. However, if a different channel is selected
between analog reads, two conversions will be necessary to return valid data from the new
channel. The analog input code example on page 50 shows how to use a 32bit SPI frame for an
automatic second conversion when only one sample is desired.
A
I
R
NALOG
NPUT
Analog inputs are in binary format, 0 to +4.095V only.
The full analog input range is divided into 4096 steps. The output code (0000h) is associated
with an analog input voltage of 0 Volts (ground). All codes are considered positive.
Sample values are shown in the following table:
EBX-11 Reference manual
C
ONVERSION
ANGE
Table 26: Binary Data Format
0 to +5V
Input
Hex
Decimal
Voltage
>+4.095
+4.095
0FFFh
+2.047
0800h
+1.023
0400h
+0.001
0001h
0.000
0000h
Comment
Out of range
4095
Maximum voltage
2048
Half scale
1024
Quarter scale
1
1 LSB
0
Zero (ground input)
Interfaces and Connectors
49

Advertisement

Table of Contents
loading

Table of Contents