wire / wire-format / pit-8253
The PIT 8253/8254 is a 3-channel timer. Channel 0: system timer (IRQ0, 18.2 Hz default). Channel 1: DRAM refresh (legacy). Channel 2: speaker (tone generation). Each channel: 16-bit counter, 4 modes (mode 0: interrupt on terminal count, mode 2: rate generator, mode 3: square wave, mode 4: software triggered strobe). Control word: 0x43 (port 0x43). Counter access: 0x40 (ch0), 0x41 (ch1), 0x42 (ch2).
aka: PIT 8253/8254 (Programmable Interval Timer)
spec: Intel 8253/8254
The PIT 8253/8254 is a 3-channel timer. Channel 0: system timer (IRQ0, 18.2 Hz default). Channel 1: DRAM refresh (legacy). Channel 2: speaker (tone generation). Each channel: 16-bit counter, 4 modes (mode 0: interrupt on terminal count, mode 2: rate generator, mode 3: square wave, mode 4: software triggered strobe). Control word: 0x43 (port 0x43). Counter access: 0x40 (ch0), 0x41 (ch1), 0x42 (ch2).
| field | size | meaning |
|---|---|---|
| Control word | 1 byte (port 0x43) | Bits 6-7: channel (00=ch0, 01=ch1, 10=ch2, 11=read-back). Bits 4-5: access mode (00=latch, 01=LSB, 10=MSB, 11=LSB then MSB). Bits 1-3: mode (000=mode 0, 010=mode 2, 011=mode 3, 100=mode 4). Bit 0: BCD (0=binary, 1=BCD). |
| Counter (ch0) | 2 bytes (port 0x40) | System timer. Default: 1193182 Hz / 65536 = 18.2 Hz. IRQ0. |
| Counter (ch1) | 2 bytes (port 0x41) | DRAM refresh (legacy, unused on modern systems). |
| Counter (ch2) | 2 bytes (port 0x42) | Speaker. Connected to PC speaker via gate (port 0x61 bit 0/1). |
| Mode 0 | mode | Interrupt on terminal count: counter decrements to 0, then IRQ. |
| Mode 2 | mode | Rate generator: periodic interrupts at counter rate. |
| Mode 3 | mode | Square wave: 50% duty cycle. Used for speaker tone. |
| Mode 4 | mode | Software triggered strobe: one-shot pulse on terminal count. |
example:
36 00
PIT control word: channel 0, LSB+MSB, mode 3 (square wave), binary
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/pit-8253
or /wire-format/pit-8253.json