Article 3334 of comp.sys.handhelds: From: frechett@boulder.Colorado.EDU (-=Runaway Daemon=-) Subject: I/O on the hp48sx Summary: Copy of HP 48 I/O Technical INterfacing Guide Message-ID: <1991Jan10.081920.19016@csn.org> Date: 10 Jan 91 08:19:20 GMT Sender: news@csn.org Organization: University of Colorado, Boulder Well, here it is. I am sure that a few of you would really like to know just how in the hell the I/O on the hp48sx really works. Well, for all you people who can't access the hpbbs and request a hardcopy of this document from the sysop, here is the HP 48 I/O Technical Interfacing Guide presented with permission in plain ASCII format. I have found this guide extremely interesting and valuable. Read the part about leaving the IO port open. ;) Two things I should say first. 1. There are NO other guides like this.. Or at least not right now. Don't ask. 2. Any errors found in my typing are purely in your imagination, as I don't make mistakes. ;) Seriously though, if you find any errors, tell me so that I can keep this updated. I will indoubtably put a copy on wuarchive.wustl.edu at some point to keep all the ftp nuts happy. Have fun with it. ian -=Runaway Daemon=- P.S. Got my 128K CMT SRAM card today. I love it already. ------------------------------------------------------------------------------ HP 48 I/O TECHNICAL INTERFACING GUIDE copyright Hewlett_Packard Company 1990 All Rights reserved. June 14, 1990 CONTENTS 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 1 2. Wired Serial I/O Hardware . . . . . . . . . . . . . . . . . . 1 2.1 Cable Wiring. . . . . . . . . . . . . . . . . . . . . . . 1 2.2 Serial Format . . . . . . . . . . . . . . . . . . . . . . 3 2.3 Serial Electrical Specifications . . . . . . . . . . . . 3 2.4 Serial UART Operation . . . . . . . . . . . . . . . . . . 4 3. Infrared I/O Hardware . . . . . . . . . . . . . . . . . . . . 5 3.1 IR Format . . . . . . . . . . . . . . . . . . . . . . . . 5 3.2 Transmit and Receive Circuits . . . . . . . . . . . . . . 6 3.3 IR Specifications and Receive Circuits. . . . . . . . . . 7 3.4 IR UART Operation . . . . . . . . . . . . . . . . . . . . 8 4. Kermit File Transfer. . . . . . . . . . . . . . . . . . . . . 8 5. Non-Kermit I/O. . . . . . . . . . . . . . . . . . . . . . . . 9 5.1 General Considerations. . . . . . . . . . . . . . . . . . 9 5.2 Special Considerations for IR . . . . . . . . . . . . . . 9 #Daemon's note. Page numbers are at end of pages. - i - 1. Introduction This document gives HP 48 hardware information required to connect serial devices to the wired (serial) I/O port or to communicate with the HP 48 via the 2-way infrared (IR) I/O port. It also gives some consideration for I/O software on devices connected to the HP 48, and should be read in conjunction with "HP 48 I/O SOFTWARE INTERFACING GUIDE" which gives suggestions for programming the HP 48. The serial I/O port is a full-duplex UART with RS-232 compatible signal level shifting. The IR I/O port uses an infrared receiver circuit for input and and LED for output, giving a half-duplex IR UART. For both serial and IR ports, incoming bytes are received in the interrupted system (when the port is open) up to 255 byte limit of the input buffer. While every effort has been made to insure the accuracy of the information contained herein, this document and any examples contained herein are provided "as is" and are subject to the change without notice. Hewlett-Packard makes no warranty of and kind with regard to this document, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. Hewlett-Packard Company shall not be liable for any errors of for incidental of consequential damages in connection with the furnishing, performance, or use of this document of the examples herein. 2. Wired Serial I/O Hardware The serial I/O port allows full-duplex communication between systems at 1200, 2400, 4800, or 9600 baud over wires with RS-232 compatible signal levels. Available parity settings are: none, odd, even, mark, or space. Parity checking of received bytes may be disabled while still transmitting with parity. XON/XOFF handshaking can be used on either of both transmit and receive. The serial I/O port is divided into separate receive and transmit sections which share a baud-rate-generator and and interrupt mechanism. Both the receiver and transmitter sections are double-buffered to maximize the throughput of the serial channel. 2.1 Cable Wiring The pin definitions for the HP 82208A (IBM) and 82209A (Macintosh) serial cables for the HP 48 are shown on the next page, including the 25 pin end of the 9-25 pin adapter. All signals are labeled from the HP 48's point of view. - 1 - HP 48 I/O Cable Pinouts ______________ Macintosh end of cable | - - - | 5 -- RX (input)---|--V V-------| 4 -- Signal GND | - - - | | ^-|--3 TX (output) \ - - / ----______---- PC end of cable with 9-25 adapter /------------------7 Signal GND | /----------3 TX (output) | | /--------2 RX (input) 13 V V V V------1 SHIELD ___________________________ \ O O O O O O O O O O O O O / \ O O O O O O O O O O O O / ----------------------- 25 14 PC end of cable /--------------5 Signal GND | /----------3 RX (input) | | /--------2 TX (output) V V V 1 _____________ \ O O O O O / \ O O O O / ------- 9 6 Notes: 1. Output = from HP 48 _________ s. Input = to HP48 | o o o o | \_______/ ^ ^ ^ ^ | | | \------ 1 SHIELD | | \---------2 TX (output) | \-----------3 RX (input) \-------------4 Signal GND - 2 - 2.2 Serial Format A frame of serial data consists of a start bit, eight data bits, and at least one stop bit. The start bit is equivalent to a "0" data bit and a stop bit is equivalent to a "1" data bit. The data bits are sent least-significant-bit first. The HP 48 transmitter sends slightly more than 2 stop bits with every frame. The HP 48 receiver requires at least 1 stop bit for proper frame synchronization. A mark condition or "1" data bit on the serial line corresponds to a negative voltage. A space condition or "0" data bit corresponds to a positive voltage. an idle corresponds to zero voltage. The line is held in this low power (idle) state when the port is closed. when the port is open, the line is normally held in the mark condition. When data is to be transmitted it must start in the mark condition. When the line is to be returned to the idle condition is must pass through the mark condition first. A break condition is when the line is held in the space condition for at least one entire frame. A break should not start in the middle of a character. 2.2.1 Example: an 'H' (48hex) 0 0 0 1 0 0 1 0 | . | . | . | . | . | . | . | . | . | . | . | SPACE +V _______________________ ___________ _____ | | | | | | SIGNAL GND -|- - - - - - - - - - - -|- - -|- - - - - -|- - -|- - -|- - - - - - | | | | | | MARK -V --- LSB ----- ----- MSB ----------- |<--->|<--------------------------------------------->|<--------->| START DATA BITS STOP BIT 2.3 Serial Electrical Specifications The following table gives the port electrical operating specifications. The TX output voltage swing is measured at the end of a 1-meter cable with the specified load, where the 500 pF includes distributed capacitance in the cable. ___________________________________________________________________________ | Signal | Description | Min | Typ | Max | Units | |===========================================================================| | |Out V swing. Load 3KOhm min, 500 pF max |+-3.0| 3.5 | | | | TX |----------------------------------------|-----|-----|-----|-------| | | Bit width tolerance | | | 2.5 | % | |--------|----------------------------------------|-----|-----|-----|-------| | | Input + operating range | 1.0 | |15.0 | V | | |----------------------------------------|-----|-----|-----|-------| | | Input - operating range |-15.0| |0.3 | V | | RX |----------------------------------------|-----|-----|-----|-------| | | Input impedance | 5.0 | | 7.0 | KOhms | | |----------------------------------------|-----|-----|-----|-------| | | Bit width tolerance | | | 2.5 | % | |--------|----------------------------------------|-----|-----|-----|-------| | All | Absolute maximum voltage | | |+-25 | V | --------------------------------------------------------------------------- - 3 - 2.4 Serial UART Operation 2.4.1 Receiver Operation Port must be open to receive data. HP 48 Kermit I/O functions, XMIT, and SRECV all open the port automatically if it is closed. The following description fo the HP 48 receiver is offered as a model for the receiver on and external device communicating with the 48. All bit timing is relative to the leading-edge of the start bit. The resolution of this timing is 16 times the baud setting. The data on the RX pin is shifted into a shift register at the center of the bit time. When the RX pin goes to the space condition (indicating the start of a frame) the receive clock starts. If the RX pin remains in the space condition for at least half a bit time, the start bit is considered valid and the receive shift register is enabled. If the RX pin returns to mark condition before a half bit time elapses, the receive clock stopped and the frame aborted. When the shift register has shifted in a start bit, eight data bits, and a stop bit, it transfers the eight data bits to the receive buffer register (RBR), sets the receive buffer full flag (RBF), and reinitializes the shift register. If the RBF flag was already set, the receive error (RER) flag is set to indicate an overrun. If the stop bit was not a "1" (mark condition), the RER flag is set to indicate a framing error. Then the receiver returns to its idle state of waiting for a valid start bit. Another incoming frame may be received while software is responding to the RBF condition. The HP 48 software reads the byte out of the RBR and places the bytes in a 255 byte input buffer. All parity checking is done in software when the bytes are read out of this input buffer. 2.4.2 Interpretation of Break Condition a break condition on the line will be interpreted as a valid start bit followed by eight zero data-bits and at least one "0" (invalid) stop-bit. Thus a break condition will result in a null byte in RBR and setting RER and RBF. The start bit filter will prevent an extended break condition from being interpreted as additional characters until the line returns to the mark condition. 2.4.3 Transmitter Operation When the port is closed, the transmit voltage level shifter is turned off to save power. The TX pin is shorted to signal ground to send a line idle condition. When the port is opened, the transmit level shifter is enabled and the TX pin goes to the mark condition. For each data byte of data, the transmitter sends 2 stop bits, 1 start bit, and 8 data bits plus 3/16 bit internal clocking delay for a total of 11.375 bits per frame. Therefore the maximum transmission rate is: Baud setting/11.375 (844 characters/second at 9600 baud) - 4 - 3. Infrared I/O Hardware The IR port allows half-duplex communications between systems at 2400 baud using pulses of infrared light instead of wires. Full-duplex is not used due to the need to suppress reflections. 3.1 IR Format The format for IR transmission is similar to serial transmission except a pulse of infrared light of 52 us duration (nominal) is used to transmit a zero-bit. the absence of a pulse indicates a one-bit or idle condition. Note that if the pulses are stretched out to fill a bit time this becomes very similar to the serial signal. 3.1.1 Example: an 'H' (48 hex) | | | | ___ | | ------------- | '------------ |<->| 52 us |<--------->| |<------------->| | 416.7 us | | 416.7 us | \_____ | | __________/ \ | | / | | | | 0 0 0 1 0 0 1 0 | | | | | | | | | | | | # # # # # # # # # # # # # # # # # # # # # -- ---- ---- ---- --------- ---- --------- ------------------- | | LSB MSB| | |<-->|<-------------------------------->|<------------>| START DATA BITS STOP BIT BITS - 5 - 3.2 Transmit and Receive Circuits The first circuit shown below detects incoming IR pulses and produces the signal shown at the left, labeled "IN". The second circuit generates the IR output given the signal shown at the left, labeled "OUT". Receive Circuit. +5V _________________________________________________ | | | 10K \ 18K \ 1M \ 1/8 W / R6 1/8W / R8 1/8W / R7 \ \ \ ---------------| | | | \ | | \| | \ Q4 |------------------| \| R4 /| | Q3 |----------/\/\/----------V <---, | /| | 220K | '----- | V | 1/8 W | | +5V _ ____ | | | | || | 560K / R5 220K / | || | 1/8W \ 1/8W \ R3 / GND -- | / / |/ | | |------------------| Q2 | | | |\ | | .022uF --- C1 V | | ___ | | | | | ---------------------------|-------------------- ---|--- --|-- - +5V --- Transmit Circuit | 39Ohms / 1/8W \ R1 Q1,Q2,Q3: 2N3904 +5V __ / Q4: EG&G VATEC VTT 9112 || | CR1: NEC SE303A || ----- --, or GND - ----- CR1 \ / '--> HP HEMP-3301 (narrower beam) --- | R1-R8: 5% / OUT R2 |/ --------------\/\/\------| Q1 ----> 500 Ohms |\ 1/8 W V ----- --- - - 6 - 3.3 IR Specifications _______________________________________________________________________ | Description | Min | Typ | Max | Units | |=======================================================================| | Wavelength | | 940 | | nm | |---------------------------------------|-------|-------|-------|-------| | Distance from transmitter to receiver | | | 2.0 | in | |---------------------------------------|-------|-------|-------|-------| | Half intensity beam width | +-20 | +-30 | | | |---------------------------------------|-------|-------|-------|-------| | Receiver pulse width | 40 | 52 | 80 | us | |---------------------------------------|-------|-------|-------|-------| | Transmitter pulse width | 46.8 | 52 | 57.2 | us | |---------------------------------------|-------|-------|-------|-------| | Baud | 2340 | 2400 | 2460 | bit/s | ----------------------------------------------------------------------- 1. Half intensity beam width is measured from the emitter's centerline to where the radiant intensity is half the on-axis value. 2. The IR transparent material used in the HP 48 card cover is GE ML4309-21051 IR TRANSPARENT FCR POLYCARBONATE. Not to scale. ___________ ____________________ | | | | _____________ | | | | | | | | | 3.200 in | | 81.3 mm | | Centerline - - - - - - - - - -|- - - -|- - - - - - ^ ^ .293 in .532 in v 7.4 mm | --------- (LED)| 13.5 mm ^ .238 in | v v 6.0 mm | --------------------- (###)| Phototransistor | | |_____________ ALL DIMENSIONS ARE NOMINAL | | ----------- --------------------- (neat picture of end of calc from end deleted) serial v-----LED (CR1) oooo O O ^---Phototransistor (Q4) (neat picture of end of calc from side deleted) Calc is 1.085 in (27.6 mm) high. IR is 0.625 in (15.9 mm) high. IR is slanted 10 degrees down from level. - 7 - 3.4 UART Operation The UART uses the transmit and receive circuits for IR output and input as described below. 3.4.1 Transmitter Operation The port must be open to transmit data. HP 48 Kermit I/O functions, XMIT, and SRECV all open the port automatically if it is closed. The output of the UART is modulated under "IR Format" and send to the output circuit. The serial port cannot be used while doing IR I/O. It's TX pin will be held in the mark condition and breaks (SBRK command) will not be sent to the TX pin but will instead generate a series of IR pulses. 3.4.2 Receiver Operation The port must be open to receive data. HP 48 Kermit I/O functions, XMIT, and SRECV all open the port automatically if it is closed. The following description of the HP 48 IR receiver is offered as a model for the receiver on and external device communicating with the 48. IR pulses from the receive circuit's "IN" signal are used to set a latch whose output is called IRE (IR Event). The receiver starts by waiting for a valid start bit. and incoming pulse of IR will start the receiver clock, which shifts IRE into a shift register after half of a vit time and then clears IRE for the next bit. Because this method stretchs the pulses, any pulse of light that is long enough to set IRE will be considered a valid start bit. The remaining bits are shifted in in the same fashion as described above for the wired UART including checking for framing and overrun errors and using RBR and RBF. As in the serial port, all bit timing is relative to the leading edge of the start bit and has 1/16th bit resolution. Due to the probability that reflections from the transmitter will be received and interpreted by the receiver, the receiver data is ignored (by disabling receiver interrupts) while transmitting. The serial port cannot be used while doing IR I/O. Its RX pin will be ignored by the UART. 4. Kermit File Transfer Kermit file transfer is preferable to unformated I/O since it can detect errors and correct them by re-transferring bad packets. The Kermit you use should be set to use type 3 (CRC) checksums for IR I/O since the error rate is higher than for wired I/O. If you use your Kermit in server mode the HP 48 will use "I" packets to request type checksums. The HP 48 Kermit does not use XON/XOFF handshaking since Kermit packets are small enought that additional handshaking should not be necessary. Your Kermit must have an input buffer which can hold at least 14 bytes in order to receive an "S" or "I" from the HP 48, although a larger buffer is clearly desirable for more efficient transfers. The input buffer must also be large enough to receive the largest "F" (filename) packet that will be sent. - 8 - 5. Non-Kermit I/O 5.1 General Considerations The HP 48 can receive a maximum of 255 bytes in a continuous stream, so to transfer more than this you should use XON/XOFF handshaking or some higher level protocol which breaks the data stream into pieces smaller than this. Data sent to the HP 48 should have inter-frame gaps less than 4 frame times or greater than 4 frame times plus 5 ms. Inter-frame gaps of between 4 frame times and 4 frame times plus 5 ms should be avoided since they may cause UART overruns on the HP 48. Be sure the clock is not ticking in the HP 48 display since clock ticks, alarms coming due, or other timer interrupts extend the 5 ms to a much longer time, so they can cause UART overruns. For the same reason, no keys should be pressed while doing I/O (unless the intent of the key press is to abort the I/O). You must allow enough time for the HP 48 to read data out of its receive buffer (using SRECV) before sending more data or the 255 byte receive buffer will be overflowed. Use of some sort of checksum is recommended, especially for IR I/O which is sensitive to noise. Garbage characters (most commonly FF bytes) can be received between transmissions since a single IR or electrical noise pulse acts as a start bit. 5.2 Special Considerations for IR Since IR from the transmitter can reflect back into the receiver, the receiver should be ignored while transmitting and carefully cleaned up after the transmitting is done. If your IR receive circuit is feeding a UART, you should wait for at least a half bit time after the stop bit from the last transmitted to be sure that reflected byte has been received before clearing the UART's receive buffer as well as any framing or overrun errors. At this point the receive circuit will be ready to receive valid data, although (as noted above) this "valid data" can contain garbage characters due to IR or electrical noise pulses. Be sure to use some reliable error detection technique if data integrity is important! Because IR I/O half duplex (due to reflections), XON/XOFF handshaking is not possible. - 9 -