10 The analogue interface
To force a particular channel to be sampled and converted next, use
*
FX17,
<
channel>, as
follows:
2010 *FX17,3
2015 REM force sampling and conversion for channel 3
2020 REPEAT : UNTIL ADVAL(0) DIV 256 = 3 : REM wait till
finished channel 3
2030 reading = ADVAL(3):REM get reading from
channel 3
Note that the
*
FX17
command forces sampling and conversion for all channels from that
specified down to 1, even if they have been turned off with
*
FX16
.
ADVAL(0) DIV 256
returns the number of the last channel to complete sampling and
conversion, or 0 if no channel has yet completed conversion since the last
*FX16
or
*FX17
command.
Using the analogue interface from assembly language
The functions of the
ADVAL
keyword in BASIC are provided by calling OSBYTE with A = &80
(128 decimal) and X = a number in the range 0 to 4, which determines the function performed as
follows:
X = 0: on exit Y will contain the number of the last channel sampled and converted, or 0 if no
conversion has yet completed (since the last
*FX16
or
*FX17
call).
X = 1 to 4: on exit X and Y will contain the last value sampled and converted for the channel
number specified in X; X contains the least significant eight bits and Y contains the most
significant eight bits. The range and significance of this 16-bit integer is as for the value
returned by
ADVAL
(see 'Using the analogue interface from BASIC').
*FX
commands can be performed in assembly language in the usual way, by a call to OSBYTE (
&FFF4). Thus, to set the number of analogue input channels, instead of using
*FX16
,
<
number>, load A with &10 and X with the number, then call OSBYTE; to force a channel to be
sampled and converted
(
*FX17
,
< channel>), load A with &11 and X with the channel number,
then call OSBYTE.
Each time the sampling and conversion of an analogue signal is completed, an `event' is
generated. If you wish to detect and act on this event, you must first
Summary of Contents for PLUS 1
Page 1: ......
Page 2: ......
Page 3: ...The Electron Plus 1 User Guide Part no 419100 Issue no 1 Date March 1984 ...
Page 11: ...Setting up 5 ...
Page 29: ...Notes ...
Page 30: ......