Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Help with sn76489 chip!

Reply to topic
Author Message
  • Joined: 16 Jun 2017
  • Posts: 3
  • Location: Sacramento, California
Reply with quote
Help with sn76489 chip!
Post Posted: Fri Jun 16, 2017 10:17 pm
Hey guys, new to the forum so thanks for letting me join.

I built a Sega Synth using the YM2612 from the Genesis, and I have put in quite a few hours on it and it works well now. I can plug in a midi keyboard and play up to 6 notes at a time (the polyphony of that chip) and am very happy with where I am on that project.

So I decided to try another chip, with the chip of choice being the TI SN76489. This chip is much simpler, although it uses the same type of logic for loading values into the registers. Specifically, you write 8-bits of data onto the data bus (pins D7 to D0) and then flash the /wr pin from HIGH to LOW, and the data gets loaded into the registers on the negative edge of the clock signal. This is my understanding of how the SN works, since this is how the datasheet explains it and is exactly how the YM2612 works.

So here is the issue I am having: I cannot reliably load data into the registers purposely. So, for example, if I want to load the binary value 0b10011111, that should change the attenuation on channel 0 (or channel 1, whatever you want to call it) to full attenuation, therefore turning the channel off. But when I execute this code, it might do something unpredictable, like it might change the frequency of one of the tones 20% of the time, and do nothing the other 80% of the time. I do have sound coming out of this chip and have the clock signal checked for the correct frequency (I am using the SN76489N, so I am using a 500kHz signal which is actually about 488 kHz. Close enough for now.) Interestingly, I wrote a program that loads random values on to the 8-bit bus, and writes them into the chip, and does this at an extremely fast rate (anywhere from two to tens of times per second) to see if loading random values would give me the expected result of generating random tones and noise. And it WORKS! So I know that my program is close to being correct, but I just can't seem to load anything on purpose. And I am confused

I have a lot of questions but I will try to keep this short and only ask the main ones. Here are my top questions:

1) could someone please explain how the READY pin works? I understand that it is supposed to go HIGH when the chip is ready to recieve another command (meaning it has finished the last command), and for now I just have a 1.5kΩ resistor connecting it to ground. This works and enables me to load data into the chip, but without this resistor (I tried an LED/resistor combo and also open circuit) it does not allow me to load data if the 1.5k resistor is not connected. I saw online that this pin is open-collector, could anybody please help explain that to me?

2) when I write data to the pin, I have to loop the write function about 20 times to get it to work. It goes like this:

(/wr pin is high by default)
byte gets sent to data pins
/wr pin goes low
delay of 1 millisecond
/wr pin goes back to high and stays there until next write command

I just don't understand why a single write command wouldn't work for this. The chip overall seems incredibly simple and I am surprised that I am having so many problems with it, haha. I have looked on tons of websites and am just trying to find anybody who can give me a little push in the right direction. I am spending hours a day on this thing and am just stuck and I feel like I shouldn't be. But isn't that what being stuck always feels like? :D

Thank you for reading and sorry if this is in the wrong section. Thanks
  View user's profile Send private message
  • Joined: 15 Sep 2009
  • Posts: 377
Reply with quote
Post Posted: Sat Jun 17, 2017 6:43 am
I can't give you answers to your questions, but I remember that when building a small sound board with 2 SN76489AN together with my father I had trouble setting registers at first.
The reason is, that TI's numbering is backwards compared to what we're used to. (D0 is the most significant bit.) The docs document this properly, but it's easy to overlook.

i.e. if you want to set attenaution of channel 0 to max (0x9F or 0b10011111) then you need to send these values to the data pins:
D0 D1 D2 D3 D4 D5 D6 D7
 1  0  0  1  1  1  1  1
  View user's profile Send private message Visit poster's website
  • Joined: 16 Jun 2017
  • Posts: 3
  • Location: Sacramento, California
Reply with quote
Post Posted: Mon Jun 19, 2017 6:18 pm
Thanks for the reply ValleyBell. The problem was that I wasn't using the READY pin correctly. I set it up to where the microcontroller will wait for the READY pin to be high before writing the next instruction, and this fixed everything. I made a sweet little drum sequencer out of it, haha. Now I just have to figure out what else to do with this thing.
  View user's profile Send private message
  • Joined: 09 Dec 2013
  • Posts: 228
  • Location: detroit
Reply with quote
Post Posted: Wed Jun 21, 2017 1:02 pm
Ever think to make a video demo of these board you've constructed, that would really be cool :)
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!