Delta Tau GEO BRICK LV User Manual

Page of 440
Turbo PMAC User Manual 
Writing a Host Communications Program
 
395
 
Example 
Let us now assume the following command has been sent to ask for the position of motor 1:
 
#1P<CR>.  
Turbo PMAC, of course, will respond with data containing position information of motor 1.  Let’s say 
that motor 1 is currently at position 19.2.  We now wish to read the mailbox registers to obtain this 
information Turbo PMAC has waiting for us.  The first thing we do is send the command line and service 
the interrupt Turbo PMAC generates (using an interrupt vector of $A0) as an acknowledgment.   
After Turbo PMAC has processed the command and put data into the mailbox registers, Turbo PMAC 
interrupts us a second time with an interrupt vector $A1.  Remember, we get this second interrupt because 
PMAC has just now placed data in the mailbox registers, now ready to be read.  We service this second 
interrupt and note that the accompanying interrupt vector is $A1, telling us to read the data in the mailbox 
registers.   
Actually, these registers may be read in any order, but it is best to read these characters beginning with 
the first mailbox register until we either:  
1. Encounter 
<CR> (signifying the end of that line)  or 
2. Encounter 
<ACK> (valid command line received)   or  
3. Encounter 
<BELL> (invalid command line received) 
or 
4.  Have read all 16 mailbox registers (from $7FA001 to $7FA01F).   
These mailbox registers mya be read as many times as desired because Turbo PMAC will not write new 
data into the mailbox registers (if Turbo PMAC has more data to send) until a value of $00 is written into 
mailbox #1 (in this case, at $7FA003).   
In this example, Turbo PMAC will have six characters waiting to be read:
 
19.2<CR><ACK>.  (We are 
assuming I-variable I3 is set to 2.)  The data will be in the registers as follows: 
Address 
$7FA001 $7FA003 $7FA005 $7FA007 $7FA009 
Mailbox # 
0 1 2 3 4 
Character 
1 9 . 2 
<CR> 
We start reading the characters at $7FA001, mailbox register 0. We see the <CR> in mailbox register 4, 
so we stop reading, and write a $00 into mailbox register 1 to tell Turbo PMAC it is OK to send more.  
Since Turbo PMAC still must send the final <ACK> it interrupts us again, and we find in the mail box 
registers: 
Address 
$7FA001 $7FA003 $7FA005 $7FA007 $7FA009 
Mailbox # 
0 1 2 3 4 
Character 
<ACK> 
9 . 2 
<CR> 
Now we start and stop at mailbox register 0, because it contains an <ACK>. Now, read in these characters 
beginning with mailbox register #0 at $7FA001.  Recall that we said never write into mailbox register #1 
when sending data to Turbo PMAC-VME.  This is because Turbo PMAC will be allowed to write new 
data into the mailbox registers as soon as we write to mailbox #1.  (Incidentally, it actually does not 
matter what value we write into mailbox register #1, it’s the fact that we write to this register that counts.  
However, it is recommended to write a value of $00 into mailbox register #1 for reasons given later.)  
After writing a $00 into mailbox register #1, we may or may not get interrupted again by PMAC, 
depending whether or not Turbo PMAC still has more data for us to read.   
Example 
Let us again assume that the following command has been sent to ask for the contents of memory locations 
X:$1000 through X:$1002:
 
RHX$1000,3<CR>.  Let’s say that these three locations contain the values 
$123456, $789012, and $345678.  We again wish to go and read the mailbox registers, so we send the above 
command line and service the interrupt PMAC generates (using an interrupt vector of $A0).   
After Turbo PMAC has processed the command and put data into the mailbox registers, Turbo PMAC 
interrupts us a second time with an interrupt vector $A1.