Pamux User’s Guide 111
GAINING AND RELEASING ACCESS
Before reading from or writing to a Pamux analog brain board, you must request access to its internal
registers. This prevents data values from being accessed simultaneously by both an AC28 (or
equivalent) and a brain board.
Gaining Access
First, write the hex value 82 to the control register (AC28 base address + Pamux address + 1). Then
read the data register (AC28 base address + Pamux address) and test bit 7 of the byte just read. Bit 7
is the semaphore bit. When the value of bit 7 is 1, the microprocessor on the Pamux brain board is
updating the contents of the RAM. Once the value of bit 7 becomes 0, you have gained access.
Once you have gained access, the value of bit 7 will continue to be 1 until you release access (as
described below).
The following function illustrates how to gain access to an analog brain board. The GetAccess
function returns True if access is gained, False otherwise. This example tries a fixed number of times
before “giving up,” but a better approach would be to try for a fixed amount of time as well. Note that
access may not be granted if there is a hardware failure.
FUNCTION GetAccess% (DataPortArg%)
CONST SemaphoreRegister% = &H82
CONST MaxTryQty% = 30
‘ Quantity of times to retry
DIM ControlPort%: ControlPort% = DataPortArg% + 1
‘ 2nd register on B6
OUT ControlPort%, SemaphoreRegister%
‘ Point to the semaphore register
DIM TryQty%
‘ Loop counter -- don’t try forever
DIM IsBusy%
‘ Non-zero if busy
FOR TryQty% = 1 TO MaxTryQty%
IsBusy% = INP(DataPortArg%) AND &H80
‘ Get bit 7
IF 0 = IsBusy% THEN
GetAccess% = -1
‘ Return True to indicate success
EXIT FUNCTION
‘ Return
END IF
NEXT
GetAccess% = 0
‘ Return False to indicate failure
END FUNCTION
PROGRAMING WITHOUT THE PAMUX DRIVER