User's Manual

PMAC User Manual
Writing a Host Communications Program 273
Real-Time Data Gathering through Dual-Ported RAM
Using the dual-ported RAM, it is possible to perform the PMAC data gathering function and upload the
gathered data to the host computer in real time. (The standard data gathering function — used by the
PMAC Executive Program to produce plots — performs the data gathering in real time, storing to open
regular RAM in PMAC, then uploads to the host afterwards.) This real-time uploading requires tight
handshaking between the host and PMAC to ensure that the data is passed reliably and efficiently.
Setting Up
The DPRAM data gathering function is set up the same way as for the standard data gathering function,
with PMAC I-Variables I19 to I44 controlling what data is to be gathered and how often. To specify data
gathering into the DPRAM, I45 should be set to 3 (it is set to 0 for the standard gathering).
The buffer for temporary storage of the gathered data is established by the DEFINE GATHER
{constant} command, where {constant} is the size of the buffer in PMAC words (each PMAC
word is 32 bits in the DPRAM). The buffer always starts at PMAC word address $D200, which from the
host side is DPRAM base address plus $0800 (2048) bytes.
Each short data source occupies one word in the buffer; each long data source (fixed-point or floating-
point) occupies two words.
Set the size of the buffer based on the number and length of the data sources, and the worst-case number
of gathering cycles that the host could fall behind in reading data from the DPRAM. This size must not
be greater than 3500 for the 8Kx16 DPRAM. Typical sizes are 20 to 100 words.
The DPRAM gathering function is started and stopped the same as for the standard gathering: either with
the GATHER and ENDGATHER (ENDG) commands, or by setting and clearing the data-gather control bits
directly through M-variables.
Getting the Data
Once the gathering function has begun, the host must monitor registers in the DPRAM that contain
pointers to the data that has been loaded into the DPRAM. There are two key registers, and only one of
these needs to be read repeatedly. At the DPRAM base address plus $07FE (2046) is the pointer to the
end of the buffer. This value is determined by the DEFINE GATHER command and will be fixed for a
given application.
At the DPRAM base address plus $07FC (2044) is the pointer to the next address where gathered data
will be placed in DPRAM. It is this register that the host should monitor repeatedly to see if it has
changed — meaning that new data has been placed in the DPRAM — and if it has changed, how many
times data has been placed.
Both of these registers contain a PMAC memory word address (actually the offset from the start of the
gather buffer, $D200). To translate into a host memory byte address, the following equation should be
used:
Host_address = (DPRAM_base_address + $0800) + 4 * (Pointer_value)
The value of the storage pointer will wrap back to 0 (PMAC address $D200) when it becomes greater
than or equal to the value of the buffer-end pointer. No item will be stored in the DPRAM starting at the
PMAC word address shown by the buffer-end pointer, although if a long item would start to be stored in
the previous DPRAM word, the second half would be placed in the actual buffer-end word.
Data Format
Data is stored in the buffer in 32-bit sign-extended form. That is, each short (24-bit) word gathered from
PMAC is sign-extended and stored in 32-bits of DPRAM (LSByte first). The most significant byte is all
ones or all zeros, matching bit 23. Each long (48-bit) word is treated as two 24-bit words, with each short
word sign-extended to 32 bits. The host computer must re-assemble these words into a single value.