PC Speaker port 0x61 bit definitions?
Posted: Fri Aug 08, 2025 2:08 pm
Hi,
I'm adding the ability to play sounds on the PC speaker. I'm a bit confused about the definitions of bits 0 and 1 on port 0x61.
https://wiki.osdev.org/PC_Speaker says bit 1 controls whether the speaker is "in" (0) or "out" (1).
It also says setting bit 0 to 1 connects the speaker to timer 2 of the PIT.
It doesn't say it, but I'm guessing bit 1 is ignored if bit 0 is 1.
The sample code sets *both* bits to play a sound. Why does bit 1 need to be set?
I found another reference, https://www.tek-tips.com/threads/port-61h.258828/, which gives different meanings to the bits.
PB1 0 turn off speaker, 1 enable speaker data
PB0 0 turn off timer 2, 1 turn on timer 2, gate speaker with square wave
where bit 0 controls timer 2. This matches https://wiki.osdev.org/Programmable_Int ... #Channel_2.
The chip set docs describe how to set bits, but not what those bits are wired to. Is there a reference for this?
On an historical note. I gather that the original IBM PC used an Intel 8255 PPI which was replaced in the IBM PC AT with an Intel 4082 UPI which maintained compatibility for port 0x61. What happened after that? Does this functionality still exist? What implements it now?
Thanks.
I'm adding the ability to play sounds on the PC speaker. I'm a bit confused about the definitions of bits 0 and 1 on port 0x61.
https://wiki.osdev.org/PC_Speaker says bit 1 controls whether the speaker is "in" (0) or "out" (1).
It also says setting bit 0 to 1 connects the speaker to timer 2 of the PIT.
It doesn't say it, but I'm guessing bit 1 is ignored if bit 0 is 1.
The sample code sets *both* bits to play a sound. Why does bit 1 need to be set?
I found another reference, https://www.tek-tips.com/threads/port-61h.258828/, which gives different meanings to the bits.
PB1 0 turn off speaker, 1 enable speaker data
PB0 0 turn off timer 2, 1 turn on timer 2, gate speaker with square wave
where bit 0 controls timer 2. This matches https://wiki.osdev.org/Programmable_Int ... #Channel_2.
The chip set docs describe how to set bits, but not what those bits are wired to. Is there a reference for this?
On an historical note. I gather that the original IBM PC used an Intel 8255 PPI which was replaced in the IBM PC AT with an Intel 4082 UPI which maintained compatibility for port 0x61. What happened after that? Does this functionality still exist? What implements it now?
Thanks.