YM2612 audio
alatnet
Posts: 80
Trying to interface a YM2612 with a propeller but i dont know if the test program is working correctly.
Test program can be found at the end of this site: http://www.smspower.org/maxim/Documents/YM2612
BOM:
-Propeller
-YM2612
-LM386 mini micro amp x2:
--Store: https://www.ebay.com/itm/LM386-DC-5V-12V-Mini-Micro-Audio-Amplifier-Module-Board-Mono-AMP-Module-HIFI-DIY/172438970072
-LTC6903CMS8:
-- Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/69034fe.pdf
-TXS0108E x2:
--Store: https://www.ebay.com/itm/8-Channel-Logic-Level-Bi-directional-Converter-Module-TXS0108E-TXB0108-Arduino/312520511001
--Datasheet: https://www.ti.com/lit/ds/symlink/txb0108.pdf
I've attached the sound that i recorded when executing my code. It might be a bit loud.
I have the program switching the key on and off by 1 second (sleep(1)) and that is noticeable in both audacity and in the audio but the thing is that the tone is always on and you can somewhat hear it go high/low.
Here's how I have my breadboard setup:
Been basing the wiring off of this: https://github.com/AidanHockey5/STM32_VGM_Player_YM2612_SN76489
Though with some modifications.
Not using a TPA3122D2 for one.
Any help would be appreciated.
Test program can be found at the end of this site: http://www.smspower.org/maxim/Documents/YM2612
BOM:
-Propeller
-YM2612
-LM386 mini micro amp x2:
--Store: https://www.ebay.com/itm/LM386-DC-5V-12V-Mini-Micro-Audio-Amplifier-Module-Board-Mono-AMP-Module-HIFI-DIY/172438970072
-LTC6903CMS8:
-- Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/69034fe.pdf
-TXS0108E x2:
--Store: https://www.ebay.com/itm/8-Channel-Logic-Level-Bi-directional-Converter-Module-TXS0108E-TXB0108-Arduino/312520511001
--Datasheet: https://www.ti.com/lit/ds/symlink/txb0108.pdf
I've attached the sound that i recorded when executing my code. It might be a bit loud.
I have the program switching the key on and off by 1 second (sleep(1)) and that is noticeable in both audacity and in the audio but the thing is that the tone is always on and you can somewhat hear it go high/low.
Here's how I have my breadboard setup:
Been basing the wiring off of this: https://github.com/AidanHockey5/STM32_VGM_Player_YM2612_SN76489
Though with some modifications.
Not using a TPA3122D2 for one.
Any help would be appreciated.
Comments
Edit: I see you have listed the TXS0108E in your parts, so you've probably covered the 3.3V to 5V translation issue.
I've attached the program that i've been using for testing, though im making more modifications to it atm.
It's using PropWare for it as i find it easy to work with.
Though i'm using a Character LCD with an I2C backpack to output debug data and will be making adjustments to it.
The wierd thing is, when im using PropWare's PWM on a pin to drive the clock of the YM2612 (either direct or through a TXS0108E), it doesnt have the overarching tone that is played but doesnt really play the audio correctly either.
Im thinking it's either that i have a bad YM2612 or I'm doing something stupid.
Turns out that PropWare SPI code doesnt work right for the LTC6903 and had to code my own to deal with it specifically.
It gets rid of the high pitched tone and actually makes sound.
The issue is that it sounds slowed downed.
I believe i need a nanosecond timer but the closest i can get is within 100 microseconds.
Looks like it is working yet i think im not sending the data fast enough or that im not delaying data enough.
The copy of your code that I downloaded last night contains this line:
I'll assume that you've actually got it wired correctly, such that the value of "MISO" is actually referring to the data pin going from the Prop to the LTC6903.
However, even if it is wired correctly, this won't work. In PropWare::SPI's constructor, MOSI is first set as an output, and then MISO is as an input. This means that, after the SPI bus is constructed, you've left your data pin as an input and no data will be coming out of it. You should, instead, write the constructor like so:
Im looking at the code and i dont see that the SPI class even sets the direction of the pins.
I was under the impression that it would set the pin directions automatically to facilitate it's function.
The PropWare::set_mosi() and PropWare::set_miso() methods also set the directions for those pins.
So it does set the pin direction "automatically" but it only does it once. No need to set the direction every time a shift in/out routine is called - that's just wasteful .
Incidentally I am familiar within reason with the TI part, it and its many kin are extremely capable of making the most amazing sounds.
anyway.
The green board at the top is a custom board that i made to work with the propeller on a breadboard more easily.
In the middle is an I2C level translator and two TXS0108E level translator to protect the propeller from 5v.
At the bottom is an LTC6903 on the left and a YTM2612 on the right with a 16x2 character lcd that uses an I2C backpack. (Above the character lcd is a cheapo breadboard power supply).
To the left is the two LM386 Micro Amps to deal with increasing the volume of the YM2612, though i've adjusted wiring a bit there atm.
You cant really see it that much but above the micro amps and behind the usb to serial adapter is a TRRS board so that i can output the audio from the amps to my computer.
Oh yea! This is slightly incorrect.
MISO stands for Master In Serial/Slave Out and MOSI stands for Master Out Serial/Slave In.
Master being the propeller in this case.
So, if i want to send data from the propeller to the LTC, i would need to use the MOSI pin.
With an SD card, DO is MISO and DI is MOSI.
EDIT: Ok, there's a lot of conflicting information about the spi pinout with an sd card...
I've always felt that MOSI/MISO are, by far, the least confusing way to refer to pins in an SPI bus. The master is, by definition, the one driving the clock. With PropWare's SPI object, that is always the Propeller. Therefore MOSI and MISO are unambiguously defined with the Propeller as master..
Getting some progress but ultimately no audio out at all.
Dont really know what im doing wrong.
Either way, I was looking through the documentation for the YM3438 and the Sega2.doc that's floating around and created a header file with defines for the various registers along with some notes about them.
Figured they might be useful for those that are also working with the YM2612.
Though some of the ascii diagrams might be a bit wonky... Should be fine in visual studio.
Got my logic analyzer and did some debugging.
Turns out the TXS0108E were causing data garbage.
Swapped them for these I2C/SPI mosfet based logic level converters and im seeing the data not get corrupted.
Need to get audio out working so I'm going to be figuring out how to create an audio circuit for this.
Why create an audio circuit when you can buy a stereo module on line for less than the parts to make one would cost.
Looks like for some reason Pin 4 is not outputting ANYTHING.
This is what it's looking like when i flash the bus:
As for my layout, it changed a bit:
For one, i have a logic analyzer now and it's been one hell of a useful tool.
Also got some new jumper wires that allowed for things to be cleaner.
Changed the TXS0108E's out for mosfet based level translators and they work great, no garbage at all.
The jumper wires off the side of them are for the logic analyzer. Makes it easier to connect it.
2. For goodness sake, what is this obsession with plug-in breadboards? Good double-sided plated through uncommitted pad matrix boards are cheap and freely available. Use socket strips if you like soldered to the matrix board, then plug in your modules. Wire it point to point underneath using Kynar wire (wire-wrap wire) which is very easy to use and solder. Then you have a compact and reliable "board". You can even use more than one board if that suits.
Here's an example
Used pins 9 through 15 for that and it works perfectly.
And i find breadboards easy to work with. Havent had issues with it and it's something that is reusable without wasting anything.
Also, tested pin 4 with a volt meter on my custom board, no issues there. Even swapped out the propeller chip itself.
I find matrix boards cheap, disposable, and reliable, they can be drilled to suit odd connectors and parts, plus I can package them in a case easily. Whereas plug-in breadboards introduce long leads and capacitance and unreliable connections. Ok for a small and slow circuit but the extent to which they get used leaves me cringing at all the things that can go wrong. Also 0.1" pads make it very easy to solder 0805 caps and resistors pad to pad, nice and close and tight and compact.
But take this as a useful suggestion, take the leap and try it out and see how well it works (and how very few problems you have with connections).
1. Breadboard for quick testing, building the circuit, and confirming that it works.
2. Then use matrix boards for what you said.
3. Finally make pcb's.
It was a god damn wiring problem...
I had D4 connected to the clock of the PSG...