Dove Systems
Home |  Products |  Pricing |  Dealers |  Free Stuff! |  Related |  PDF Files |  Support |  Contact

Talking to the Stars - Part 1

This 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.

StarPort timing diagram

Write Handshake

A 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 Handshake

The 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.

Parameter Timing
Write data setup 20 nS min
Write data hold 20 nS min
Write acknowledge 5 uS typ
Table 1 - StarPort write timing

Write Data

Data 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 Commands

The 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 01

As 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 Pointer

The 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 Pointer

The 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 Addresses

On 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.

Memory Address Contents
0:0x408 Low half of LPT1 I/O address
0:0x409 High half of LPT1 I/O address
0:0x40a Low half of LPT2 I/O address
0:0x40b High half of LPT2 I/O address
0:0x40c Low half of LPT3 I/O address
0:0x40d High half of LPT3 I/O address
Table 2 - Printer Port Address Table

Printer Port Registers

Each 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.

Register Number Contents Read/Write
0 Data Read/Write
1 Status Read Only
2 Control Read/Write
Table 3 - LPT port registers
DB25 Pin Register Bit StarPort Signal Description
1 -C0 -WR Active low write strobe. Pulse low to capture write data
2 +D0 D0 Byte wide data written to StarPort
3 +D1 D1
4 +D2 D2
5 +D3 D3
6 +D4 D4
7 +D5 D5
8 +D6 D6
9 +D7 D7
10 +S6 -DataAck Low indicates StarPort has requested nibble on TxD0..TxD3
11 -S7 -TxD3 ACTIVE LOW MSB of nibble mode data from StarPort to host
12 +S5 TxD2 Active high bit of nibble mode data from StarPort to host
13 +S4 TxD1 Active high bit of nibble mode data from StarPort to host
14 -C1 -DataRq Host pulls line low (by setting bit high) to request nibble of data
15 +S3 TxD0 LSB of nibble mode data from StarPort to host
16 +C2 Not used by StarPort
17 -C3 Not used by StarPort
18 to 25 Ground Ground Ground
Table 4 - StarPort DB25 pin out.

PseudoCode

Psuedocode 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


                               // A check of TxD0 for handshake should be done before or after this is called.
Output data to PortAddress     // Place data byte on data lines
Output 0x01 to PortAddress+2   // Drive -WR line low
Output 0x00 to PortAddress+2   // Drive -WR line high

ReadNibble


                                                     // Get a nibble from the StarPort.
Output 0x02 to PortAddress+2                         // Force -DataRq low, requesting data from StarPort
Loop until ((in(PortAddress+1) & 64) ==0)            // Wait for -DataAck to go low
  RxData=(7 & (in(PortAddress+1)>>3))                // Get receive data D2..D0, shift into proper place and mask out rest
  if ((in(PortAddress+1) & 128) ==0) RxData=RxData+8 // Add in D3. Note it is inverted
    Output 0x00 to PortAddress+2                     // Force -DataRq high
    Loop until ((in(PortAddress+1) & 64 != 0)        // Wait for -DataAck to go high
  endif
endloop
return(RxData)

ReadByte


                                     // Get a byte from the StarPort by doing two ReadNibbles.
RxData=ReadNibble()                  // Get low half
RxData=RxData + (ReadNibble()<<4)    // Get high half, shift left 4 bits and add in
return(RxData)

SetPointers


// Set StarPort pointers to bottom of buffers. Successive reads and 
// writes will go to successive buffer addresses in StarPort
// due to autoincrement. 
WriteToStarPort(0x01)                    // Send command prefix
Wait for in(PortAddress+1) to change     // Wait for handshake
WriteToStarPort(0x40)                    // Set read pointer to bottom of buffer
Wait for in(PortAddress+1) to change     // Wait for handshake
WriteToStarPort(0x00)                    // Send low half of read buffer address
Wait for in(PortAddress+1) to change     // Wait for handshake
WriteToStarPort(0x01)                    // Send command prefix
Wait for in(PortAddress+1) to change     // Wait for handshake
WriteToStarPort(0x82)                    // Set write pointer to bottom of buffer
Wait for in(PortAddress+1) to change     // Wait for handshake
WriteToStarPort(0x00)                    // Send low half of write pointer address

WriteData


                                       // Sends data to StarPort, waits for handshake, and traps 0x01 data.
WriteToStarPort(data)                  // Send byte to StarPort
Wait for in(PortAddress+1) to change   // Wait for handshake
if (data==0x01)
  WriteToStarPort(data)                // Send 0x01 data twice
  Wait for in(PortAddress+1) to change // Wait for handshake
endif
Home |  Products |  Pricing |  Dealers |  Free Stuff! |  Related |  PDF Files |  Support |  Contact
www.dovesystems.com