PROGRAMING WITHOUT THE PAMUX DRIVER
4-10
Pamux User’s Guide
To release access, write a hex 82 to the control register, then write anything to the data register. The
function below illustrates how to do this in QBasic. The ReleaseAccess function releases access by
simply writing any value to the semaphore register.
SUB ReleaseAccess (DataPortArg%)
CONST SemaphoreRegister% = &H82
CONST Anything% = &HFF
DIM ControlPort%: ControlPort% = DataPortArg% + 1
‘ 2nd register on B6
OUT ControlPort%, SemaphoreRegister%
OUT DataPortArg%, Anything%
END SUB
READING AN ANALOG CHANNEL
Remember that before reading an analog channel, you must first gain access to the internal
registers, as described previously.
After gaining access, write the position to be read to the control register, then read the contents of
the data register to get the least significant byte. Increment the contents of the control register, then
read the data register to get the most significant byte. Remember, I/O instructions are done one byte
at a time, and an analog value is a 12-bit value (0–4095).
The following example continuously reads an analog input and prints the value to the screen.
DIM HaveAccess%
‘ Non-zero if we have access
DIM DataPort%: DataPort% = MyAc28IoPort% + MyAnalogBoard%
DIM ControlPort%: ControlPort% = DataPort% + 1
DIM LowerByte%
DIM UpperByte%
DIM AnalogValue%
DO WHILE 1
‘ Loop until ctrl-break
HaveAccess% = GetAccess%(DataPort%)
IF HaveAccess% THEN
OUT ControlPort%, MyAnalogInputChannel% * 2
‘ Select a channel
LowerByte% = INP(DataPort%)
‘ Read lower byte
OUT ControlPort%, MyAnalogInputChannel% * 2 + 1
UpperByte% = INP(DataPort%)
‘ Read upper byte
AnalogValue% = CombineUpperAndLowerBytes(UpperByte%, LowerByte%)
PRINT AnalogValue%
‘ Print result
ELSE
PRINT “No Access”
END IF
CALL ReleaseAccess(DataPort%)
LOOP
IMPORTANT:
Don’t forget to release access to the brain board if this is the last operation you will be doing on
this pass.
Содержание PAMUX
Страница 10: ...TABLE OF CONTENTS x Pamux User s Guide...
Страница 14: ...TABLE OF CONTENTS xiv Pamux User s Guide...
Страница 103: ...PROGRAMING WITH THE PAMUX DRIVER 3 42 Pamux User s Guide...
Страница 121: ...PROGRAMING WITHOUT THE PAMUX DRIVER 4 18 Pamux User s Guide...
Страница 125: ...TROUBLESHOOTING AND TIPS A 4 A 4 A 4 A 4 A 4 Pamux User s Guide...
Страница 135: ...SPECIFICATIONS B 10 Pamux User s Guide...
Страница 141: ...TEMPERATURE CONVERSIONS ROUTINES C 6 Pamux User s Guide...
Страница 143: ...PRODUCT SUPPORT D 2 Pamux User s Guide...
Страница 149: ...GLOSSARY E 6 Pamux User s Guide...