I'm working on a project which uses the Texas Instruments SN76489 integrated circuit, which was used to make sound in arcade games and Sega games from the 80's and 90's, I believe. I made a similar project with the Yamaha YM2612m which is the main sound chip from the Sega Genesis, and I have that project fully up and running and can play through vintage Sega sounds on a midi keyboard, up to 6 notes at a time. Probably not a huge deal to you guys but its the biggest project I have done so far.
So I am now working with the SN76489 and am having some issues. The way it works is that it has 8 internal 8-bit registers, and these are controlled via an 8-bit bus of data pins on the IC. In order to write data to these registers, the data is written to the pins of the IC (d0 to d7) and a separate write enable pin which is active low (/wr) gets flashed from a logic high to a logic low, and this latches the data from the data bus into the chip. Just going over things for the record.
So here is the issue I am having: I cannot seem to reliably load data into the chip on purpose. To test it out, I wrote a program which writes random values to the data pins, and then flashes that /WR pin low in order to write the data to the chip. It does this about 10 times per second, with the expected result being that the chip would generate random tones and noise sounds. And this part works absolutely as expected, so I know that my write function works, at least in this application.
However say, for example, I want to turn off channel 0. This is done by sending the byte 0b10011111) which sends the value "1111" to the attenuation register of channel 0. If I execute code which does this, and then execute the write command, it will not do what I expect it to do. 80% of the time it doens't do anything, and maybe the other 20% of the time it changes something unexpected like the frequency (pitch) of one of the other channels. I was able to get these commands working correctly briefly, but in order to do this, I had to loop that write command algorithm about 20 times in order to get it to work every time. Does anyone know why this might be?
I am very confused about several parts of this project because it seems like it should be quite simple so maybe I am quite an idiot lol. I am using a clock signal of 500 kHz (measured at 488 kHz) because I am using the SN76489N as opposed to the SN76489AN. I looked at my clock signal and it is very clean looking, and I feel that my error is somewhere in the execution of my code since it seems to work on the hardware level.
One last thing I am confused about is the READY pin (pin 5.) This pin is supposed to go high when the chip is ready to receive its next command (meaning, it has finished executing its last instruction.) However this never seems to be the case, as I put an LED on this pin and it seems to stay low the entire time, unless the current from this pin is not enough to power an LED. I should look at this under the scope. For now I have a 1.5 kΩ resistor pulling the pin down to ground, and I saw somebody explain on a forum somewhere (maybe this one actually) that this is an open-collector pin which is internally connected a 2.2kΩ resistance. I just know that the write commands will work 0% of the time if this pin is not pulled down with the resistor, but I have no idea why. I apologize if I seem very incapable to you guys, I know there are some very smart engineers on this forum.
So anybody who has worked with this chip or similar ones, I would very much appreciate some guidance from you although I do enjoy these projects and the inevitable banging my head on the desk until I can't feel my face anymore. This is the joy of engineering.
Also I will be glad to post code or schematics if they will help. I will draw up a diagram later today and post it, as well as my code after I get something to eat. I am food deprived, another sacrifice I have made for this project, haha.
Thank you Will
Thanks to everyone, especially Tony Stewart. The issue was on the ready pin, sure enough. The solution was to connect the ready pin to one of the inputs of my microcontroller (Arduino) and wait for this pin to be high before writing the next instruction to the chip. This solved the problem and I am now getting beautiful tones out of this thing, haha. Thanks again