Arduino and the Texas Instruments SN76489

You may have never heard of the Texas Instruments SN76489, but if you are reading this article, there’s a good chance you have heard it.

The SN76489 is a sound chip which, according to the Wikipedia entry, was used in systems such as:

…and in arcade games such as:

…and many more. I am just naming the machines and games I have heard of or seen/played.

Side Note: The Wikipedia entry also claims the Sega Genesis used one, but it had far fancier sound. A quick search shows the Genesis did not use this chip, so other systems may also be incorrect. Ah, Wikipedia…)

This chip is able to produce three tones and one white noise at a time, which sounds an awful lot like the audio capabilities of my first computer, the VIC-20.

The chip has none of the fancy synthesizer features found in other chips, such as the famous Commodore 64 SID chip. The only thing you can do is adjust the volume level of each channel of sound. Clever software uses this to produce bell sounds and other effects. (If Congo Bongo is really using this chip, it’s doing some fancy things to make those bongo sounds!)

Thanks to StrongWare‘s John Strong, I now have one of these chips to experiment with. It is wired up to an Arduino Nano clone. (NOTE: I had issues getting this clone recognized on my Mac, due to it using a different serial chip. I found the solution, and wrote about it earlier this week.)

SN76849 sound chip hooked to an Arduino Nano on a neat 3-D printed platform from StrongWare.

John pointed me to this short tutorial on how to use the chip:

http://danceswithferrets.org/geekblog/?p=93

Using sample code there, I was able to get the device making tones, and then expanded it to play a sequence of tones to make a tune.

The next day I added more code so it could do a multitrack sequence.

I thought it might be fun to share what I have learned the first two days of playing with the device, and share the code I have come up with.

I will do a full article on the chip and how it works (summarizing some overly complex explanations I have been reading), but until then, here is my sample project:

https://github.com/allenhuffman/MusicSequencerTest

It contains routines to poke bytes to the SN76489, plus a work-in-progress multitrack music sequence that currently plays the 2-voice intro music to Pac-Man :)

I’ve been fixing up the comments and squashing some bugs, so check back for the latest. I still have to add real/better support for the “noise” channel, but it works right now for playing simple tunes.

More to come…

20 thoughts on “Arduino and the Texas Instruments SN76489

  1. Pingback: Introducing the Sir Sound CoCo Sound Card | Sub-Etha Software

  2. Michiel

    I’m getting a srange hummmmm sound which wont go away. Music is played, with that humm.
    The Arduino Nano and SN76489 are connected as on the http://danceswithferrets.org/geekblog/?p=93 page.

    I tried your MusicSequencerTest.ino too. It worls fine. The hummm dirves me nuts.

    Stuff used;
    – Arduino Nano
    – 4 Mhz clock osc.
    – SN76489AN audio chip.

    All help appreciated!

    Reply
    1. Allen Huffman Post author

      Yeah, it’s noisy. There may be some circuitry that could be added to reduce the hum, or it could just be the cheap part is noisy. Mine has a hum but it’s not too bad unless you turn the volume up.

      Reply
  3. shawtyds

    @Michiel, I can answer the question for your Hum :-)

    By default when the SN76489 is powered on, it emits a continuous tone on channel 2, to let you know that it’s getting a clock signal and everything started up ay-ok.

    Problem is, unless you initialize the chip in a very specific way, it seems to stick around like a bad smell, and is very difficult to get rid of. The reason it’s difficult to get rid of, is because of a bug in the hardware on the chip. I don’t know the exact details of the bug, but I do know it’s there, and how to stop it.

    I was a dedicated Acorn BBC Model B dev back in the 80’s/90’s (Still am… ish :-) ) but I was also one of only a handful of people who figured out how to use that hum to force the SN to play back digitized sampled sound on a BBC Model B micro, and as a result was one of the reasons so many games had very primitive sample sounds in them on that machine.

    ANYWAY… back to this….

    I’m just on uploading all my project files for an arduino setup I put together, to allow me to playback actual BBC Model B music data from a PC, to an SN chip, using an Arduino to control the chip, it’s nothing flash, BUT….. if you look in the arduino code that’s there, you’ll see a function to correctly initialize the chip, and get rid of that annoying hum.

    My Project is at:

    https://github.com/shawty/sn76489arduino

    Iv’e not finished the circuit diagrams yet, I’ll get them done soon, but all the codes there, and as soon as I finish typing this, I’m gonna upload a bunch of sample VGM files containing genuine SN76489 music data too.

    @Allen – how about mentioning the BBC Micros A/B/B+/Master/Master 128/Master 512 and Master ET-Turbo too :-) No one who does anything with these wonderful little sound chips ever mentions them, they deserve a bit of the lime light too (Please) :-D

    Shawty
    (@shawty_ds – on twitter)

    Reply
    1. Allen Huffman Post author

      I’ll take a look at your code. The BBC machines were never over here in the States, so beyond knowing that “BBC Micro” was a thing from some 80s computer TV show (probably a BBC show actually), I never heard of it until recent internet years. I also learned about the MSX, since it has an extended PLAY command in BASIC that does multi voice an I have a serial controlled sound player I am sorta modeling after that version of Microsoft BASIC.

      Reply
  4. shawtyds

    Ah, that makes sense (The State Side thing) – Yea the BBC Micro was huge over here.

    You had 2 groups of children in 80’s geek culture, you had your Sinclair Specrum/Amstrad crowd, they where the one that became the games players of the generation, and ultimately moved onto the Commodore Amiga & the Atari ST etc

    Then you had your hardcore geeks that took things apart, build things, and generally abused machines like the BBC Micro (It’s hardware capabilities where immense for the time). The BBC Micro folks where the ones that went on to do careers in computer engineering, robots, communications, electronics all that kind of stuff, and ultimately grew up through the ranks ending with the Acorn Archimedes Series and RiscOS.

    Ultimately though we all ended up on the PC Platform in one way or another :-(

    If your really interested in this side of the pond, look for a book called “Digital Retro” by “Gordon Laing”, it covers the MSX, The BBC Micro and many, many more machines of the era both sides of the Atlantic.

    Ultimately what I want to do with my version of the Arduino player, is to set it up so that it can be used by my BBC Micro emulator, and instead of emulating the sound, can use real hardware to play it.

    What I want to do next, is to figure out how to program my Arduino so that it appears to windows as a USB Hid device, then write a driver of some kind for it that can then be detected, rather than depending on comports.

    The circuit diagram (When I get it done) is almost identical to the one ‘danceswithferrets’ came up with, and if you need a source for the chips, there’s a number of suppliers here in the UK that seem to still have them available, I get mine from a company called “Electro TV Parts” (They have an eBay page).

    Shawty

    Reply
    1. Allen Huffman Post author

      It looks like my Radio Shack Color Computer followed a similar paths… over here, the Commodore guys were the gamers, and the CoCo folks go into multitasking OS-9 operating systems and device drivers and such.

      Reply
      1. shawtyds

        Quite likely. I do know the Radio Shack (or it’s UK version which I owned at some point “The Tandy TRS-80” was a reasonably powerfull machine.

        I have to confess though, I know very little about US geek culture. :-)

        +1 for “The Micro Men”, great film just for watching, even if your not into that kind of thing.

        Reply
        1. Allen Huffman Post author

          I have a project called SirSound which uses a Microsoft BASIC PLAY command parser and a serial port. I hook it to my CoCo, and using the BASIC command to print to the printer serial port, and can make it play autonomous background music. I’ve done much work on the sequencer and such since I first posted this, so I will have to get a full update posted. I’ve learned much.

          Reply
          1. shawtyds

            Kewl.

            Well it’s been a LOOOOOOONG time since I touched anything like that. (I’m a profession software developer by trade by the way) , I’m more used to dealing with multi million line C#, Java and web projects these days, but I’m always happy to take a look at small bits of code here and there and offer my opinion and/or help.

  5. shawtyds

    Sweet. Yea i was doing too much software and starting to miss the hardware side of things, thats why I started getting back into arduinos/pi’s etc.

    Shawty

    Reply
    1. Allen Huffman Post author

      I’ve never been a hardware guy, beyond soldering some serial cables, but I’m getting pretty good at plugging wires into breadboards and hooking things up. Having a blast! Wish I had learned this thirty years ago.

      Reply
  6. shawtyds

    Thirty years ago, dang that’s almost as long as Iv’e been in the I.T game :-)

    My first professional I.T job was in 1988, for a year while I studied one day a week to do a BTEC In computer studies. Then I swanned off and joined the Army for 3 years, did networks, radio, communications all that jazz, came back out circa 1992, wen’t on to university graduated with a 3 part degree in 1995 in CPU Design, Industrial Robotics and Software Engineering practices, wrapped up under an umbrella of “Computing for Industry”

    Spent some time doing everything from Game music (Worked on a lot of the 1990’s era Amiga/Atari titles and late 90’s C64 titles) to being a sysadmin building data centers etc, then 4 and a half years in the comms industry working for orange as a radio access networks engineer.

    I wrote a large chunk of the radio access software for the (Then new) 3G service they where rolling out in the UK.

    Since then Iv’e worked all over the world, 3 of my biggest clients are in the USA, Iv’e had clients in the middle east, europe, australia, these days I’m happy just being a self employed code slinger with my own ltd company.

    Keeps me happy, pays the bills and keeps me out of trouble :-)

    I wrote my first bit of code however, way back in 1979 on a Sinclair ZX81 with 1k memory :-)

    Reply
  7. ⁧ シーク⁨Sik (@Sikthehedgehog)

    Coming here just to point out something:

    “Side Note: The Wikipedia entry also claims the Sega Genesis used one, but it had far fancier sound. A quick search shows the Genesis did not use this chip, so other systems may also be incorrect. Ah, Wikipedia…)”

    It does have it (specifically the same one as the Master System, with its slightly different noise generator), but it’s also coupled together with a YM2612 which is the one doing the fancier sounds. Probably the most iconic use of the SN76489 on the system is when Sonic jumps :P (there’s also the opening of Streets of Rage if you’re looking for music instead of sound effects, and the noise channel was commonly used for hithats in general)

    Note: you won’t find any actual SN76489 chip if you look at the board since they integrated it into the same chip as the video hardware.

    Reply
    1. Allen Huffman Post author

      Thanks for this info! When I did some digging. I read it was the Master System chip, and just assumed whoever did that entry didn’t know the difference between those two Sega units.

      Reply

Leave a Reply