9.6 Read the A/D data

Once the conversion is complete, you can read the data back from the A/D converter in two 8-bit bytes at Base + 0 and Base + 1 (see page 17). The low byte must be read first. The following pseudo code illustrates how to construct the 16-bit A/D value from these two bytes:

LSB = read(Base) ;Get low 8 bits first

MSB = read(Base+1) ;Get high 8 bits last

Data = MSB * 256 + LSB ;Combine the 2 bytes into a 16-bit value

The final data ranges from 0 to 65535 (0 to 2^16 -1) as an unsigned integer. This value must be interpreted as a signed integer ranging from -32768 to +32767.

As noted above, all A/D conversions are stored in an on-board FIFO, which can hold up to 1024 samples in enhanced mode or 512 samples in normal mode. Whenever you read A/D data you are actually reading it out of the FIFO. Therefore, you can read each A/D sample as soon as it is ready, or you can wait until you take a collection of samples (up to 1024 maximum) and then read them all out in sequence.

Last updated