Page 1 of 1

PC Speaker port 0x61 bit definitions?

Posted: Fri Aug 08, 2025 2:08 pm
by MarkD
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.

Re: PC Speaker port 0x61 bit definitions?

Posted: Fri Aug 08, 2025 8:35 pm
by Octocontrabass
MarkD wrote: Fri Aug 08, 2025 2:08 pmWhy does bit 1 need to be set?
When bit 1 is set, the speaker position is controlled by the timer 2 output. When bit 1 is cleared, the speaker is forced to the "low" position regardless of whether the timer 2 output is low or high.
MarkD wrote: Fri Aug 08, 2025 2:08 pmThe chip set docs describe how to set bits, but not what those bits are wired to. Is there a reference for this?
IBM published schematics in their technical reference manuals.
MarkD wrote: Fri Aug 08, 2025 2:08 pmOn 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
You mean 8042?
MarkD wrote: Fri Aug 08, 2025 2:08 pmwhich maintained compatibility for port 0x61.
They actually used a couple of simple logic chips (74ALS175 and 74ALS244 according to the schematic) to implement a backwards-compatible port 0x61. The 8042 only responds to port 0x60 and 0x64.
MarkD wrote: Fri Aug 08, 2025 2:08 pmWhat happened after that?
Not much. IBM added an extra function to bit 7 for Micro Channel, but I don't know if that made it into any newer chipsets.
MarkD wrote: Fri Aug 08, 2025 2:08 pmDoes this functionality still exist?
Mostly yes. It is a legacy thing, though, so it might go away as hardware starts to drop legacy BIOS support.
MarkD wrote: Fri Aug 08, 2025 2:08 pmWhat implements it now?
The chipset. It's been part of a massive all-in-one chip since the 90s, and the only thing that's changed since then is which other functions are also part of that massive all-in-one chip.

Re: PC Speaker port 0x61 bit definitions?

Posted: Sat Aug 09, 2025 2:06 pm
by MarkD
Thank you so much. This all makes sense now. The link to the IBM system docs is amazing. Actual schematics!
I've requested wiki access to propose new wording to the Speaker page.
Thanks.