YM2612 write/read/register select
Moderator: BigEvilCorporation
YM2612 write/read/register select
Hi all, this is my first post here!
I'm doing some hardware interfacing between a YM2612 and a Teensy++, but I'm having a little trouble getting started. I hope you can help.
I expected that I would be able to select register 22h, then write 0x0F (pins 0, 1, 2, 3 high and pins 4, 5, 6, 7 low), then select 22h again and read from it. I was expecting to get 0x0F back. Instead I appear to get all zeroes every read.
Should this work? If I read, should I see the contents of the currently selected register?
This is my process:
1. Reset pin high, CS pin low (these will never change)
2. RD high, WR high, A0 low, A1 low
3. Write 22h on the 8 data pins
4. RD high, WR low, A0 high, A1 low
5. Write 0x0F on the 8 data pins
6. RD high, WR high, A0 low, A1 low
7. Write 22h on the 8 data pins
8. RD low, WR high, A0 high, A1 low
9. Read the 8 data pins
Is this correct?
Thank you for taking the time to read my post! I really appreciate it.
I'm doing some hardware interfacing between a YM2612 and a Teensy++, but I'm having a little trouble getting started. I hope you can help.
I expected that I would be able to select register 22h, then write 0x0F (pins 0, 1, 2, 3 high and pins 4, 5, 6, 7 low), then select 22h again and read from it. I was expecting to get 0x0F back. Instead I appear to get all zeroes every read.
Should this work? If I read, should I see the contents of the currently selected register?
This is my process:
1. Reset pin high, CS pin low (these will never change)
2. RD high, WR high, A0 low, A1 low
3. Write 22h on the 8 data pins
4. RD high, WR low, A0 high, A1 low
5. Write 0x0F on the 8 data pins
6. RD high, WR high, A0 low, A1 low
7. Write 22h on the 8 data pins
8. RD low, WR high, A0 high, A1 low
9. Read the 8 data pins
Is this correct?
Thank you for taking the time to read my post! I really appreciate it.
Hi,
you should talk with sigMate, he did (almost) the same thing :
read this post
viewtopic.php?t=1122
you should talk with sigMate, he did (almost) the same thing :
read this post
viewtopic.php?t=1122
-
- Very interested
- Posts: 292
- Joined: Sat Apr 21, 2007 1:14 am
Re: YM2612 write/read/register select
Sadly you can't read from any of the registers. They are all write-only, and reading from any of the four addresses only returns the status flags.
Re: YM2612 write/read/register select
This helps so much man, thanks for the info.Charles MacDonald wrote:Sadly you can't read from any of the registers. They are all write-only
Does anybody know if my process up top is correct? I haven't gotten the chip to produce any audio yet. I currently have 10k pull-down resistors connecting MOL and MOR to ground. Can I then connect my headphones in parallel to the 10k resistors?
-
- Very interested
- Posts: 292
- Joined: Sat Apr 21, 2007 1:14 am
Re: YM2612 write/read/register select
Not quite, but you almost have it. When you output a value on the data bus, you need to bring WR low then high. Only then can you change the data to a new value and start a new write. Think of the rising edge of WR latching the data in the chip.Does anybody know if my process up top is correct?
So writing looks like this:
1. CS=L, RD=H, WR=H, output the data value you want on the data bus
2. CS=L, RD=H, WR=L, don't change the data
3. CS=L, RD=H, WR=H, don't change the data
Now you can repeat this process for a new write.
It's a nitpick, but some chips (maybe not the YM2612) depend on CS going high again after a read or write. So the complete sequence is:
Idle:
CS=H, RD=H, WR=H, Addr=Any, Data=Any
Write:
1. CS=H, RD=H, WR=H, Addr=Your address, Data=Your data
2. CS=L, RD=H, WR=H, Addr=Your address, Data=Your data
3. CS=L, RD=H, WR=L, Addr=Your address, Data=Your data
4. CS=L, RD=H, WR=H, Addr=Your address, Data=Your data
5. CS=H, RD=H, WR=H, Addr=Your address, Data=Your data
CS means the address lines are valid, so only change A1,A0 when CS is high. It may work on the YM2612 to keep CS low and change A1,A0 however, but that would be sort of a non-standard way of using the chip.
You need an amplifier to drive headphones (or a speaker). Don't connect either directly to the YM2612. I think somebody posted here earlier (or maybe it was on SMS Power with the YM2413) about doing that and the chip got hot and died since it can't handle the load.I haven't gotten the chip to produce any audio yet. I currently have 10k pull-down resistors connecting MOL and MOR to ground. Can I then connect my headphones in parallel to the 10k resistors?
At least with the YM2413 I ran the output into a LM348 op-amp configured as a voltage follower, and then the output of that into the line-in input of my PC soundcard. This way I didn't need a dedicated amplifier IC. There are probably other ways to do this.
Can't wait to see (err, hear) the results of your project!
man you guys are amazing, thanks a lot! I'll definitely post vids and a howto if I get this working!
I can't believe so many people are working on stuff like this, it's crazy awesome. This forum seems really active.
I just shot a few bux over via http://gendev.spritesmind.net/page-help.html
I can't believe so many people are working on stuff like this, it's crazy awesome. This forum seems really active.
I just shot a few bux over via http://gendev.spritesmind.net/page-help.html
I posted that it will get hot but I think there is more to that I am under an impression that I may have bought a relabeled part. I have heard alot of people having trouble with SID chips and the ym2612 is also a "famous" sound chip too so I think that what may be under in the plastic may not be ym2612 or I may have been doing something wrong. I have checked my wires many times. I have got two and I am interested in decaping one I do have a good CNC router that could aid in the process. Here is a picture of both of the ym2612 I bough
Edit image too big click on thumbnail to see full res.
Edit image too big click on thumbnail to see full res.
My crappy code is here if you want to test your chips against it: http://7355608.net/sketchbook/ym2612/ym2612.ino
I have pins d0 through d7 connected directly to the Teensy++ pins 0-7 and everything else clearly declared at the top of the file. The only nonstandard things I did were:
Used two 10k resistors to connect MOL and MOR each directly to ground (pull-down resistors)
Connected an LM386 just as suggested here to MOL as a voltage follower, attached my speaker's + to the output of that and - to ground.
There's also a status LED on pin 45.
I use a 7.68mhz 4-pin crystal oscillator to drive øM
This should run on an Arduino Uno with only changing constants. You should still use pins 0-7 for the data bus pins.
I have pins d0 through d7 connected directly to the Teensy++ pins 0-7 and everything else clearly declared at the top of the file. The only nonstandard things I did were:
Used two 10k resistors to connect MOL and MOR each directly to ground (pull-down resistors)
Connected an LM386 just as suggested here to MOL as a voltage follower, attached my speaker's + to the output of that and - to ground.
There's also a status LED on pin 45.
I use a 7.68mhz 4-pin crystal oscillator to drive øM
This should run on an Arduino Uno with only changing constants. You should still use pins 0-7 for the data bus pins.
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
You can keep !CE low all times, the YM won't mind it. !WR and !RD do have to be pulsed to do a write or read.
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 292
- Joined: Sat Apr 21, 2007 1:14 am
Congratulations on getting it to work! This is a cool project and the Teensy seems like a good fit for FM soundchips.
On the flip side the circuit does work and that's all that matters!
@sega16:
Ah, so the chip was good and in working order after all?
Just FYI the LM348 isn't really intended to drive headphones/speaker directly, but it's fine for driving a line-in input. So like if the circuit stops working in a month, maybe the LM348 burned out.Connected an LM386 just as suggested here to MOL as a voltage follower, attached my speaker's + to the output of that and - to ground.
On the flip side the circuit does work and that's all that matters!
@sega16:
Ah, so the chip was good and in working order after all?
I actually have the lm348 plugged into an amplifier I scrounged from a set of pc speakers so I think it's OK for now. I just wanted to give sega16 the simplest possible explanation for getting his chips in a known state. Without the amplifier it's so quiet you can just barely hear it, but it's enough to know the chip is working.
I'm really glad you got your circuit working dude, your "too hot" thread was really helpful to me (I didn't know I would need pulldown resistors on the outputs until I read it).
I'm really glad you got your circuit working dude, your "too hot" thread was really helpful to me (I didn't know I would need pulldown resistors on the outputs until I read it).
Yep it is all good It was my fault that it did not work I tried alot of things so I ended up assuming it was dead but now it works just fine. It turns out that my code was wrong and the reason it got hot is still unknown to me. I have better find a dual op amp I think I have one some wear or is it ok to just plug it directly into my microphone jack?
I wouldn't, use the lm348 and/or a proper amplifier.
I did some more work today; I made a very rudimentary VGM file parser. So far I've only used it with that one btc.vgm file, a recording of Behind the Circuit from Phantasy Star 4. If you build it with gcc in Linux or mingw, it will read from the file "btc.vgm" and barf text to stdout that you can paste into your code. I made it based on this doc: http://www.smspower.org/uploads/Music/v ... 7f0e3bd1ee
code here: http://7355608.net/sketchbook/ym2612/
(temporary url, might disappear any time)
btc.ino is some sample barf if you want to fool with it and don't have Linux. The timings are all messed up so it doesn't sound good and skips portions but you can definitely tell that the proper notes are getting played.
I also made some janky edits to ym2612.ino so it can access the 2nd set of registers.
The idea is that if I can parse VGM files, I can eventually extract instrument voices from them that can be used to make a rad midi synthesizer. It does sound kind of cool to play a real song from one of my favorite games when I was a kid, though, so I might put the effort into handling the delay cycles properly. I'll also have to figure out a way to play recordings that doesn't involve pasting it into my code lol
I did some more work today; I made a very rudimentary VGM file parser. So far I've only used it with that one btc.vgm file, a recording of Behind the Circuit from Phantasy Star 4. If you build it with gcc in Linux or mingw, it will read from the file "btc.vgm" and barf text to stdout that you can paste into your code. I made it based on this doc: http://www.smspower.org/uploads/Music/v ... 7f0e3bd1ee
code here: http://7355608.net/sketchbook/ym2612/
(temporary url, might disappear any time)
btc.ino is some sample barf if you want to fool with it and don't have Linux. The timings are all messed up so it doesn't sound good and skips portions but you can definitely tell that the proper notes are getting played.
I also made some janky edits to ym2612.ino so it can access the 2nd set of registers.
The idea is that if I can parse VGM files, I can eventually extract instrument voices from them that can be used to make a rad midi synthesizer. It does sound kind of cool to play a real song from one of my favorite games when I was a kid, though, so I might put the effort into handling the delay cycles properly. I'll also have to figure out a way to play recordings that doesn't involve pasting it into my code lol
Last edited by foobat on Sat Oct 13, 2012 3:22 am, edited 1 time in total.