|
Talking to the Stars - Part 1This document discusses the parallel printer port protocol used to communicate with the Dove Systems StarPort. It applies to StarPorts with red LEDs. StarPorts with green LEDs use a different protocol described in part 2. Users can use this information to write software that takes advantage of the StarPort's DMX transmit and receive capabilities. The StarPort receives a DMX signal and places the data in 512 bytes of an internal RAM buffer. Application software can read this buffer through the standard printer port "nibble mode." The StarPort continuously transmits 512 bytes of DMX data (plus framing and a start code of 0x00). The data to be transmitted is contained in another 512 bytes of the internal RAM buffer. The entire RAM buffer is available to the applications program, though a typical application would read the received data buffer and write to the transmit buffer. Independent read and write data pointers are autoincremented after each read or write. A typical applications program sets the write pointer to the bottom of the transmit buffer space, then sends each DMX channel's data to the StarPort. The application would then set the read pointer to the bottom of the receive buffer space, then read each channel's DMX data in sequence.
Write HandshakeA very simple two wire handshake is used to write data to the StarPort. Data is placed on the data lines, the -WR line is pulsed low. Data is captured on the trailing positive edge of the -WR strobe. The -WR strobe should be at least 1 microsecond wide. Data needs to be valid at least 20 nanoseconds before the positive edge of -WR and held 20 nanoseconds after that edge (20 nS set-up and hold times). The StarPort will acknowledge receipt of the data by inverting the TXD0 line. The write acknowledge typically occurs 15 microseconds after the positive edge of -WR. The StarPort advances its write pointer as it toggles TXD0. Once the data has been acknowledged, another byte may be sent to the StarPort. A typical write procedure would read TXD0 prior to sending the strobe, then sample TXD0 looking for a change. It is suggested that such a procedure include a timeout to keep the system from locking up should the handshake fail. Read HandshakeThe StarPort uses the standard "nibble mode" to read data from the printer port. The applications program forces -DataRq low. The StarPort puts the least significant half (D0 to D3) of the current read data on the TXDATA lines (TXD0 to TXD3) about 5 microseconds later. The StarPort drives -DataAck low about 5 microseconds after valid data is available. After the applications program reads the data (the four least significant bits), the applications program drives -DataRq high. About 2 microseconds later, the StarPort drives -DataAck high. The applications program can then drive -DataRq low to get the four most significant bits of the current byte. Once again, the StarPort drives -DataAck low indicating valid data is available. After the applications program has taken the data, it drives -DataRq high. The StarPort drives -DataAck high about 2 microseconds later, as it advances the read pointer to the next byte of data to be sent.
Write DataData is written to the StarPort using the write handshake described above. Note that a write of a 01 is considered to be the prefix to a StarPort command. If the data to be written to a particular location is to be a 01, send the 01 twice. StarPort CommandsThe StarPort has three commands. These are write 01, set READ pointer, and set WRITE pointer. Each command is initiated by sending a 01 to the StarPort. The command consists of the next byte or two sent to the StarPort. Write 01As mentioned in Write Data, above, a 01 is interpreted as a command prefix. A 01 followed by another 01 is interpreted as a command to write 01 to the current write location, then increment the write pointer. Applications software can include a 01 check as data is sent to the StarPort, sending any 01 data twice. Set Read PointerThe read pointer points to the next data to be read from the StarPort (in nibble mode). The DMX receive buffer is in locations 0 to 511 (0x00 to 0x1ff) of the StarPort RAM, with DMX channel 1 landing in location 0. Unused channels are set to zero. To set the Read Pointer, send the 01 command prefix followed by 0x40+bbb (where bbb is address bits A10 through A8), followed by another byte representing A7 through A0. To set the StarPort read pointer to the bottom of the receive buffer space (pointing at received DMX channel 1), send the byte sequence: 0x01, 0x40, 0x00. Set Write PointerThe write pointer points to the next data location to be filled by a write. The DMX transmit buffer is in locations 512 to 1023 (0x200 to 0x3ff) of the StarPort RAM, with DMX channel 1 landing in location 512 (0x200). At start up, all RAM locations are cleared, so DMX channels not set by the applications program will be transmitted as 00. Note that the StarPort always transmits 512 DMX channels. To set the Write Pointer, send the 01 command prefix followed by 0x80+bbb (where bbb is address bits A10 through A8), followed by another byte representing A7 through A0. To set the StarPort write pointer to the bottom of the transmit buffer space (pointing at transmit DMX channel 1), send the byte sequence 0x01, 0x82, 0x00. Printer Port Base AddressesOn IBM compatible computers, the BIOS sets up a table of 16 bit I/O addresses for printers LPT1 through LPT3. The contents of this table are listed in table 2.
Printer Port RegistersEach printer port has three registers associated with it. These are at the base address+0, base address+1, and base address+2. Table 3 lists the contents of each of these locations. Table 4 lists the pin out of the StarPort DB25 connector (which matches that of an IBM compatible computer parallel printer port). Most pins have a particular register bit associated with them. A plus sign in front of the register bit designation indicates the pin is active high. Writing a 1 to a write register will result in a high on that pin. Putting a high logic level on an input pin will result in a 1 in the appropriate status register bit. A minus sign in front of a register bit designation indicates that the pin is active low. A 1 in a register bit represents a logic low on the pin. Data pins are represented by D. Status pins (inputs) are represented by S, while control pins (outputs) are represented by C. Finally, the number in a register bit designation corresponds to the bit position in the register. A 7 is the most significant bit, while a 0 is the least significant bit.
PseudoCodePsuedocode for several StarPort functions is listed below. The programmer should be able to develop applications code from this information. Note that you can either read or write from the StarPort at a particular time (even though the timing diagram appears to show both simultaneously). You can intermix reads and write, but -DataRq and -WR should not both be low simultaneously. For simplicity, this pseudocode uses loops while waiting for acknowledgements from the StarPort. Your code might use a state machine or timer based interrupts to poll the StarPort, allowing a limited form of multitasking. WriteToStarport
ReadNibble
ReadByte
SetPointers
WriteData |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home |  Products |  Pricing |  Dealers |  Free Stuff! |  Related |  PDF Files |  Support |  Contact |