"Using" an Atari Pokey Chip with a Teensy 4 or 4.1?

jonathan322

Well-known member
I have a copy of Atari 7800 "Ballblazer," which contains a Pokey sound chip. If I desolder it from the board, is there any way to "use" it (for playing music) via a Teensy 4 or 4.1? I also have a teensy audio board (Rev.D) to use with it, if necessary.

I thought it would be a fun project, making a synth or something from it, but I'm not really familiar with the chip, so I wouldn't know where to start.

Any suggestions?

Thanks!

Jonathan

PS I have no interest in actually playing Ballblazer, so I have no qualms about wrecking the game cart. :p
 
The answer is very much yes—you can easily find several videos of people using a microcontroller to control a POKEY on a breadboard, some with links to source on GitHub—and everything you need to a know about controlling the chip is contained within this manual.

That said, I do quite a bit of work with vintage PSGs, and if you’re asking this question, be forewarned: Programming the chips is usually extremely simple; writing drivers to actually produce good/interesting audio with them is not. I highly recommend using search terms such as POKEY playback routines and POKEY reverse engineered, as well as wading into archive.org, as you’ll find a lot of suggestions from pages from the late 90s and and early 2000s that no longer exist elsewhere.

Be prepared to review quite a bit of ancient assembly.
 
Thanks. Starting with the basics, is this something to be bit banged, or is something more elegant and precise required? What about clocks? I only have one, so I guess that precludes stereo?
 
The POKEY is so rudimentary that I don’t think bit banging in the traditional sense is necessary or worthwhile, though you could certainly try to do what I’m doing with the YM2149 (note that I have over a hundred YM2149s with more on the way, and am building a synth that uses a bank of somewhere between 6 and 12 of them, so I can afford to destroy a few), described in the post, as of this moment, directly beneath yours:

Send random data to registers within known bounds—as the YM2149 has been heavily tested, there are only a couple of pins I’ll be genuinely bit banging—and use an NPU to compare audio you’d like to try to recreate to the audio output from the chip. As you only have one to work with, I’d suggest being a little bit more cautious, and an NPU would only be useful for training and comparison, not parallel testing.

Regarding stereo, you do have a couple of options. You can bifurcate the output into the right and left ADC channels of, to start, the Teensy Audio Shield, and use some clever DSP to create moderately interesting stereo effects. This would work for both live play and recording. For recording only, the world is your oyster, as you can record each part of a track separately and mix them however you’d like using a DAW.

I don’t know how crazy you want to get at this stage, but my synth is controlled by a Teensy 4.1, has two analog audio outs for live play, and can send every channel of every YM2149 to custom Reason Rack Extensions via AES67 so every individual channel can be soft-wired to other Rack Extensions for production purposes.
 
Last edited:
Well, you seem to know a bit about this! Since I'm not reading a keyboard or potentiometers, is there a minimal setup I can use? What about the audio output (Pin 37)? Does that need to go to an amplifier? I would imagine I just need to connect the data and address lines, and not much else? Do I need to run a clock at 1.79mhz? Etc., etc., etc.

All I really want to do, at the outset, is have the darn thing beep a note or two :p
 
All I really want to do, at the outset, is have the darn thing beep a note or two :p

Good—in that case, you should be able to get going in no time with The Breadboard Pokey Project and POKEY sound chip experiments.

Though the POKEY was intended to be far more powerful than the AY-3-8910 and YM2149, it suffers from serious flaws as regards timing and producing accurate frequencies—and in the end, less can be accomplished with the chip—hence the lack of widespread use, documentation, and availability (don’t get me wrong—all of these chips have flaws, and that’s part of the fun!), but one thing worth noting is that datasheets from the time period in which these chips were developed are often overly-cautious, and sometimes contain outright inaccuracies.

To whit: According to Yamaha, the max clock speed of the YM2149 is 4MHz, but the chip can be clocked up at up to 8Mhz before any audio distortion or heat issues arise. Don’t go too crazy if you’re not ready to shell out for another POKEY or two, but don’t be afraid to experiment with modest under/overclocking. Also note you can heatsink the things to near infinity.
 
Yeah - I just shelled out for another one. Ya know, just in case. I like to have a back-up.

You seem to be quite enamored with the YM2149. Any particular reason(s)?
 
Nostalgia for one, but also the ability to produce extremely rich music from what is functionally little more than a square wave generator with a few clock dividers, that it remains the primary audio chip with which people are still pulling off new tricks in the demoscene, and primarily because, by creating a synthesizer that uses a bank of the chips, I can produce a highly interesting combination of unique retro/modern sounds and instruments… primarily to rework an EP I considered ready for mastering last November until the bug to develop this synthesizer grew large enough to override my desire to release it right away.

The synth, along with the custom MIDI controller I’ve developed to use it for live performance, are part of a one-woman electronic music act I’ve been developing furiously since recovering from 18 months of Long COVID. I’ve been writing and producing music for over 25 years, but haven’t had a desire to perform or share my work publicly (largely because I have an enormous slew of personal and professional interests, and can’t juggle all of them at once) since I was in my late teens/early 20s.

Now, a couple of decades later, I finally have the opportunity to contribute something worthwhile to the medium, along with the time, skills, and financial resources to do it.
 
The synth, along with the custom MIDI controller I’ve developed to use it for live performance, are part of a one-woman electronic music act I’ve been developing furiously since recovering from 18 months of Long COVID. I’ve been writing and producing music for over 25 years, but haven’t had a desire to perform or share my work publicly (largely because I have an enormous slew of personal and professional interests, and can’t juggle all of them at once) since I was in my late teens/early 20s.

Now, a couple of decades later, I finally have the opportunity to contribute something worthwhile to the medium, along with the time, skills, and financial resources to do it.

That's very cool (and thanks for sharing all that!). I got into retro electronics during COVID, revisiting the ins-and-outs of 70s, 80s, and 90s retrotech that I never really delved into in their day; for the most part, I was too young at the time, and I didn't have any access to the nuts and bolts of these things (the ways and means). I was a deprived child - I had a CoCo (1 & 3). That community (Rainbow Magazine, etc.) was outside the 6502 "scene" - which is far more interesting than the MC6809. In my opinion, anyway. I have really enjoyed learning about all these things I either missed out on or never even knew about. Though, a few friends of mine had Atari 800s... and I was very jealous!
 
Here’s a simple question, @Stephanie Wallace . Can I simply run Pin 37, audio out, from a pokey into one, or both, of the Line Ins on a Teensy Audio Shield? Would I need any resistors, or anything else, to connect that audio out to line-level inputs properly?
 
No, you definitely don’t want to connect the audio out pin directly to an analog input. You’ll need to first place a 1K resistor to a short line out from pin 37, then wire that, at the very least, to a capacitor and another resistor to filter the DC offset, reduce jitter, and ensure the maximum voltage applied to one of the analog inputs is less than 3.3V. You’ll also need to use a bidirectional logic level shifter for every digital pin connected to the Teensy, and considering the number of digital pins, you might want to use up to two shift registers.

Let me take a quick look at a couple of POKEY wiring schematics, and I’ll provide a little bit more information in a moment.
 
Well, shit, would you look at this.

GitHub user ‘brianmarkpeters’ has already created a Teensy/dual POKEY synth. The comments that head the .ino even contain a BOM. A couple of notes:

- This project was done using a Teensy 2.0, and it won’t run as written, but after looking at the source, it will be extremely easy to rewrite—and of course, unless you wait until the other POKEY arrives you’ll need to adapt it for one chip… though if you don’t have the logic level converters, shift registers, and other components on-hand, you might as well wait.

- I know this is a little redundant, but just to ensure you don’t fry your MCU: Keep in mind the Teensy 2.0’s pins are 5V tolerant, but the 4.1’s are not, so the logic level converters are absolutely necessary.

- If you *do* have everything you need to get started, you don’t need to use more than one analog pin for stereo; using the Teensy Audio Tool, you can wire the input from one pin to each USB audio channel, and do some DSP for stereo effects beforehand if you’d like. Note that the graphical tool just produces the minimum code necessary to get started, but it’s still helpful if you’re not familiar with the audio library.

Once you get some audio out of the chip, share a clip with us!
 
Well, shit, would you look at this.

GitHub user ‘brianmarkpeters’ has already created a Teensy/dual POKEY synth. The comments that head the .ino even contain a BOM. A couple of notes:

- This project was done using a Teensy 2.0, and it won’t run as written, but after looking at the source, it will be extremely easy to rewrite—and of course, unless you wait until the other POKEY arrives you’ll need to adapt it for one chip… though if you don’t have the logic level converters, shift registers, and other components on-hand, you might as well wait.

- I know this is a little redundant, but just to ensure you don’t fry your MCU: Keep in mind the Teensy 2.0’s pins are 5V tolerant, but the 4.1’s are not, so the logic level converters are absolutely necessary.

- If you *do* have everything you need to get started, you don’t need to use more than one analog pin for stereo; using the Teensy Audio Tool, you can wire the input from one pin to each USB audio channel, and do some DSP for stereo effects beforehand if you’d like. Note that the graphical tool just produces the minimum code necessary to get started, but it’s still helpful if you’re not familiar with the audio library.

Once you get some audio out of the chip, share a clip with us!

Yeah, the schematic is very helpful - great find! And, yes, I do find myself using logic level converters often, because all the vintage/retro stuff has +5V logic. So, I have a handful of 8-bit shifters handy. I also happen to have 1.8432mhz oscillators, as I use those with my WDC65C51s.

This is fortuitous!

I guess I can wire the ultimate outputs to the Audio Shield line-level inputs and use it as a mixer?
 
Excellent all around—I look forward to some bleeps and bloops, and perhaps even more!

And indeed, the line-level inputs accept analog signals. It will be easier to reduce the range to fewer than 3.3 volts, but fret not; the STGL5000 has an amplifier on-chip.
 
It will be easier to reduce the range to fewer than 3.3 volts, but fret not; the STGL5000 has an amplifier on-chip.
Great! That's what I was hoping you'd say; I will definitely use that to mix the two chips for stereo out. I'm now checking to see if I can acquire any more of these (assuming that the price is reasonable). I don't love the idea of having to pull the chips myself; they're soldered right into the board (no IC socket).
 
I don't love the idea of having to pull the chips myself; they're soldered right into the board (no IC socket).

Plus one less piece of working, vintage equipment in the world! I’m only hoarding YM2149s because they’re still inexpensive and widely available—I don’t want be the person responsible for raising their price from $2-$3/per chip to $50.

I make heavy use of sockets while developing hardware, as I rarely use breadboards—just for very occasional, basic testing—thus prefer not to risk vintage ICs or very expensive ICs while iterating… and in the case of something like this synthesizer, which I’d like to potentially use for decades, I need to have an abundant supply of YM2149s and use sockets for them, as they need to be extremely easy to replace upon giving out.
 
I make heavy use of sockets while developing hardware, as I rarely use breadboards—just for very occasional, basic testing—thus prefer not to risk vintage ICs or very expensive ICs while iterating…
Agreed. I never solder IC pins to boards. Never. Sockets or solderless breadboards.

My second pokey is coming tomorrow - very excited to do this!
 
Exciting! I look forward to seeing what you create. I was considering snagging a couple to play around with myself, but christ are they expensive. So much so that 400/800/1200XL motherboards on eBay usually come without the POKEY, which is sold separately because $$$.

One of the reasons I’ve been able to procure so many YM2149s is because they were used in tons of consoles, arcade cabinets, gambling machines—for which a replacement clone is produced by Winbond to this day (I’d love to get my hands on the datasheet, which I’ve thus far been unable to find)—and even one NES game titled, appropriately, “Gimmick!”, for which the PCB in the cartridge contained a YM2149 to get around the NES’s extremely shitty audio chip… to hilariously poor results.

After you’ve gotten some audio out of them, if you’re inspired to take on a larger project, I highly recommend using FlexIO to drive the chips. You’ll have very tight control over the POKEYs while taking most of the load of driving them off of the CPU… not to mention, you can also use FlexIO to create a 6502 or 68k* bus if you want to get really vintage.
_________

*If you have an NXP commercial account, which is free-of-charge, there are some excellent FlexIO tutorials, including a tutorial for creating a 68k bus and a tutorial for creating an 8080 bus.
 
Exciting! I look forward to seeing what you create. I was considering snagging a couple to play around with myself, but christ are they expensive. So much so that 400/800/1200XL motherboards on eBay usually come without the POKEY, which is sold separately because $$$.
Oy - tell me about it! I'm so nervous handling these things.

After you’ve gotten some audio out of them, if you’re inspired to take on a larger project, I highly recommend using FlexIO to drive the chips. You’ll have very tight control over the POKEYs while taking most of the load of driving them off of the CPU… not to mention, you can also use FlexIO to create a 6502 or 68k* bus if you want to get really vintage.
_________

*If you have an NXP commercial account, which is free-of-charge, there are some excellent FlexIO tutorials, including a tutorial for creating a 68k bus and a tutorial for creating an 8080 bus.
Yeah, I looked at the NXP application notes a while ago, but I couldn't find the way to create the 6502-style parallel bus. The sample file that was supposed to be attached to the app note was absent :(
 
Hope you'll share photos or a demo video when it's built?

I will most definitely be sharing the completed project!

Not only photos and a video, but a lossless version of the track I've been painstakingly composing directly via register values—not only as an exercise in creating never before developed techniques for producing unique audio from the chip sans post-processing, but also as a a means of polishing the driver so those techniques can be used at a high level of abstraction—as well as a GitHub repo containing the schematics for a version of the board with one's choice of spring jacks or XLR jacks in place of the 40-pin DIP slots, with all necessary files for printing the PCB, a BOM, the VHDL for the FPGA which sends all of the channels, sampled at 24bits/96KHz, via AES67 to a USB 3.2 port using Ethernet over USB (interestingly the audio must be recorded at this fidelity and sample rate to accurately capture the pseudo-random noise channel, which produces extremely fast, 17 bit audio). I also plan to write a thorough FlexIO overview and tutorial in addition to KurtE's examples, as it's one of the most undervalued and underused components of NXP's i.MX RT series, and if time allows, create and maintain a repository for highly detailed Teensy documentation.

As various arrays of chips are being used for specific purposes, I've written a driver that allows one to use these techniques at a high level of abstraction. While I will likely wait a year or two before I release source for the drivers, as I'd like to get some of my work out into the world before others begin figuring these techniques, they are free to be reverse engineered for the pleasure of the demoscene. The source for interacting with the FPGA will be available in the aforementioned repo; I'm creating this version of the board so others who would like to send a large number of audio channels to a DAW via a single cord can do so, as well as develop their own synthesizers/audio generators, without spending the outrageous, entry-level price of such a rack, which hovers around $2K.

Frustratingly, I initially intended to use an RT1176, which has nearly all of the features necessary to implement the entire project without the use of an FPGA—and because I hope (but make no assumptions!) my favorite microcontroller engineering business (��) is likely to eventually release a new iteration of their flagship product using this chip or another similarly capable chip, at which point the board would no longer need the chip, and could instead be connected to a microcontroller with a fully-fledged framework which would allow one to used additional features of the chip to control other hardware.

As plenty were available for folks who only needed a handful when I began working on the PCB, I chose this direction, and when my first prototype was roughly 75% complete, I discovered there were no long an RT1176s to be found. I intend to return to this model as soon as the chip shortage allows, but for now, I have an EP to rework and release.

The chip shortage has proven to be an enormous pain in the ass for several projects I'm developing, and I can't imagine how much more frustrating it must be for you.

Edit:

Also of note: Due to the original nature of the project, I have already begun implementing AES67 for the Teensy 4.1 over NativeEthernet. As I intend to return to using the MCU for audio transmission, I also intend to complete the AES67 library. Due to some constraints of the 4.1 I won't be able to reach the theoretical maximum number of streams over a 100Mbps connection (8, each of which typically contain 8 bidirectional channels), but I should be able to reach at least half, and as the protocol is highly efficient as regards memory bandwidth, this means 32 bidirectional 24 bit/96KHz channels can be streamed with latency well below 1 millisecond while leaving plenty of overhead for other operations.

We'll soon see what can be achieved, and I'll be more than happy if that's only 16 channels. Though current-gen SoCs with 1Gbps Ethernet interfaces are not yet widely available due to the chip shortage, they will hopefully be in high-volume production within a year's time, and due to increased on-chip memory and faster external memory speed, we should be able to get much closer to the theoretical maximum at 1Gbps, numbers close to 640 bidirectional channels—which oughtta be enough for anyone! (I'll see myself out...)—should be feasible, if wildly unnecessary.

Once complete, if you're interested, I'd be happy create a pull request for review and possible inclusion in Teensyduino.
 
Last edited:
Back
Top