saturnus docs
Open the app

The serial port and infrared

One UART in the Clarke or Yorke chip drives both the wired serial port and the infrared LED. It sends and receives one byte at a time, with a holding register in each direction, and the system's interrupt handler moves the bytes to and from a buffer in RAM. Kermit and XModem run on top of it (see Kermit and XModem).

At a glance

Frame1 start bit, 8 data bits, the lowest first, at least 1 stop bit
Speeds1200, 2400, 4800 and 9600 baud on the wire; 2400 on infrared
Paritynone, odd, even, mark or space, checked in software
Throughputat most about 844 bytes a second at 9600 baud
LevelsRS-232 compatible, about ±3.5 V out, up to ±15 V in
Buffersone byte each way in the UART, 255 bytes for input in RAM
Flow controlXON/XOFF in software, if asked for; no hardware handshake lines
Infraredthe same UART, half duplex, a pulse for each 0 bit

Which models have it

ModelWired serialInfrared
HP 48SX, 48Syestwo-way
HP 48G, 48G+, 48GXyestwo-way
HP 38Gyestwo-way
HP 39Gyestwo-way, to another 39G
HP 40Gyesnone
HP 49Gyesnone
HP 42S, 27S, 17B, 17BII, 19BII, 28Snoneone way, to HP's 82240 printer

The HP 48 FAQ says the 49G was sold without infrared because teachers in some countries feared the 48's infrared would be used to cheat. The 49G and the 40G come with a cable from calculator to calculator instead.

The frame and the speeds

A frame is a start bit, eight data bits sent lowest first, and the stop bits. The HP 48 sends slightly more than two stop bits: 11.375 bit times for each byte, which limits it to about 844 bytes a second at 9600 baud. Its receiver needs only one.

The speed is a 3-bit code in the hardware registers. The eight codes give 1200, 1920, 2400, 3840, 4800, 7680, 9600 and 15360 baud, but the system offers only 1200, 2400, 4800 and 9600. The HP 49G FAQ notes 15360 baud "internally", which no PC supports. Both directions share one baud generator.

Parity is not done by the UART. All eight bits go through it, and the system adds or checks a parity bit in software when it takes bytes from its buffer. So the calculator can send with parity and not check it on receive.

The line

HP's I/O technical interfacing guide for the 48SX gives the electrical side:

HP's own cables connect the calculator straight to a PC's serial port. The line is not a 3.3 V or 5 V logic signal: such a board idles at a positive voltage, which the calculator reads as a space. Cables tells which cable fits which model.

Early HP 49G units, with a serial number below 94xxxxxx, have a weak transmitter that swings only about −3.6 V to +4 V into 3.3 kΩ and ramps instead of switching. Some PC ports misread it. The fixes are an internal patch or a small external buffer powered from the PC's RTS and DTR lines.

Receiving and sending

The receiver times each frame at 16 times the baud rate, from the start bit's leading edge. A start bit has to stay at space for half a bit, or the frame is dropped as noise. Then:

  1. A status bit says a character is coming; an interrupt can be enabled for that.
  2. After the stop bit, the byte is in the receive register, a "buffer full" bit is set and, if enabled, an interrupt raised.
  3. The handler reads the byte, which clears the bit, and puts it into the 255-byte input buffer in RAM.

If a byte arrives before the last one was read, the UART sets an error bit (overrun); a stop bit that reads 0 sets it as well (framing). A break, the line held at space for a whole frame, reads as a null byte with the error bit set.

Sending is the other way round: a write to the transmit register sets a "buffer full" bit, the UART moves the byte to its shift register and clears the bit, and when the byte is out it can raise "transmit empty". While a character goes out, the handler lights the transmitting annunciator.

One timing rule matters to anyone writing a sender. A gap between incoming bytes of between four frame times and four frame times plus 5 ms can cause overruns, and timer interrupts (the shown clock, alarms) or key presses stretch those 5 ms. So a computer sending to an HP 48 should send bytes back to back, or pause clearly between them.

Infrared

The infrared link uses the same UART. A bit in the hardware registers switches it from the wire to the infrared LED and receiver; while infrared is in use, the wired transmitter stays at mark and its receiver is ignored.

The system can also drive the LED directly, bit by bit, without the UART. That is how the 48 prints to the HP 82240 infrared printer, which uses its own one-way protocol. The Pioneer models (17B, 17BII, 27S, 42S) and the 28S and 19BII have only that: an infrared printer port and no serial link.

In the 49G, which has no infrared, the bit that turns the LED on became the flash memory's write enable (see Memory).

Self-test output

When the 48 runs its self-tests (ON with D or E), it also writes the results to the serial port at 9600 baud, 8 data bits, no parity, whatever the user's settings.

Sources