User's Manual

PMAC User Manual
Writing a Host Communications Program 265
The key to reading data from PMAC through the mailbox registers is that writing to mailbox register #1
permits PMAC to place its data in the mailbox registers when it has something to say. This can be done
ahead of time; effectively pre-enabling the PMAC response. This is the strategy used in all of the
following examples.
If not pre-enabling, write to mailbox register #1 only when immediately expecting a response, which is
usually after acknowledging the $A0 interrupt (see examples). If this is not done, PMAC will not
interrupt with the $A1 vector. (The only real advantage in not pre-enabling is that the middle of a long
PMAC response can be broken to issue a command.) Note that if using the pre-enable strategy, pre-
enable once after power-up or reset. Refer to the flowchart in figure 3-1 after reading the following
examples.
Example 1:
This command line has been sent to PMAC: #1J+<CR>. This command line is not a request for any
data, so PMAC will not respond with any data except an acknowledge <ACK>, signifying an
acknowledgment of receipt of a valid command line (if an invalid command was sent, a <BELL>
character would be sent instead of <ACK>). In this case, PMAC will generate an interrupt, sending with
it an interrupt vector $A0 (as defined in PMAC register X:$0789). After seeing this interrupt and
accompanying interrupt vector, the VME master or host computer must properly service or acknowledge
this interrupt so that PMAC will withdraw its interrupt assertion. (Generally, when servicing any VME
interrupt, the interrupt vector will be available.)
PMAC will then interrupt again, this time with interrupt vector $A1, signifying there is new data in the
mailbox registers to be read. Now, read mailbox register #0 (at $7FA001) to pick up the <ACK>
character put there by PMAC, if desired, but this is only necessary to verify that the command line just
sent was received as a valid command by PMAC. Finally, write $00 into mailbox register #1 (location
$7FA003), allowing PMAC to write new data into the mailbox registers if necessary (also read the next
example to better understand this). The next example shows how to read data written in the mailbox
registers by PMAC.
Example 2:
Assume the command to ask for the position of motor 1 #1P<CR> has been sent: PMAC, of course, will
respond with data containing position information of motor 1. Motor 1 is currently at position 19.2. To
read the mailbox registers to obtain this information PMAC has waiting. The first thing to do is to send
the command line and service the interrupt PMAC generates (using an interrupt vector of $A0) as an
acknowledgment.
After PMAC has processed the command and put data into the mailbox registers, PMAC interrupts a
second time with an interrupt vector $A1. Remember, this second interrupt is sent because PMAC has
just now placed data in the mailbox registers, now ready to be read. Service this second interrupt and
note that the accompanying interrupt vector is $A1, read the data in the mailbox registers.
Actually, these registers can be read in any order, but it is best to read these characters beginning with the
first mailbox until either:
a <CR> (signifying the end of that line) or
a <ACK> (valid command line received) is encountered or
a <BELL> (invalid command line received) is encountered or
all 16 mailbox registers (from $7FA001 to $7FA01F) have been read.
These mailbox registers may be read as many times as needed because PMAC will not write new data
into the mailbox registers (if PMAC has more data to send) until a value of $00 is written to mailbox #1
(in this case, at $7FA003).