96 CHAPTER 9. ANALOG TO DIGITAL CONVERSION
this to 1 if you want scanning; or else, set it to zero. Bit #4 is the MULT bit. Set
this to 1 if you want multiplexing; or else, set it to zero. Bits #3-#0 specify which
PORT E pin you want to measure. In the multiplexed mode, you can specify any
of the four pins that are part of the multiplexed group.
9.5.3 Making sure you have valid data
Once you have initiated the conversion, you have to make sure you that you have
valid data. HC11 will turn on bit #7 of ADCTL once all four conversions are
complete. It is your responsibility to check this bit before reading the converted
values.
9.6 A trial dry run
We will first do some analog to digital conversion without writing any programs.
1. Make the appropriate electrical connections. Make sure that you connect
PE7 to PE3, VRL to ground and 5V.
2. First turn on the convertor by storing $80 to location $1039. You do this
with the memory modify command: MM 1039 and entering the value 80.
3. Since it is going to take lot more than 100 microseconds for you to type
anything, there is no need for any waiting for the A/D to warm up. Now we
will configure the A/D to be in non-multiplexed, scan mode to measure PE3.
We do this by entering the bit pattern 00100011/ in location $1030. The
hexadecimal representation for the bit pattern is $23, and we need this for
memory modify command. Use the command MM 1030 and enter the value
23.
4. Adjust the input voltage so that it is one volt. use the command
md 1030 1030
and write down the first five numbers. Note that the contents of location
$1030 is A3 and not 23. This because HC11 will turn the 7th bit at location
$1030 when the conversion is completed. The next four values should be
approximately 255/5 or 51 in decimal or 33 in hex. Verify that the next
four values are approximately 33.
5. Change the input voltage. Do a memory dump to see what the converted
values are. Since we configured the analog to digital convertor to be in the
Kommentare zu diesen Handbüchern