A question of clocks and divisions

Hi all,

I'm dipping my toes in unfamiliar waters but then you never learn unless you challenge yourself and learn.

I'm using the Atmega32U4 and using it to "replicate" the sound system of the old MegaDrive/Genesis. I have gone through the original schematics, timing and technical details to get as much information I need and looked around on google about clock dividers and oscillators. There are two sound ICs in this system, the YM2612 and the Sn76489. The YM runs at the original 68000 CPU's 7.670453 MHz, the latter at a slower 3.579545 MHz, same as the Z80 in the original console. Looking at the original schematics, all the clock devisions are done within the VDP (YM7110) which takes a 53.693175 MHz master clock from a 4 pin oscillator package and divides it by 7 for the YM chip and 15 for the 76489 to make the two mentioned frequencies.

From what I can see, I can either try to just simply replicate the original design and divide the clocks from a master 53~ MHz clock using the two divisions above, or I could just give each chip it's own oscillator. Space and cost isn't too much of a concern given the project wouldn't be commercial and the case and board have ample space, but for ease of system design and keeping the chips happy with one another, I'm perhaps thinking a main system clock would make sense? If so, what would be the best route given the divisions are odd numbers?

Also, if I would be using the latter, would it be better I run the Atmega chip of the system clock but at the relevant frequency (and compensated in code ofc)?

I apologise in advanced if this seems painfully obvious or my reasoning is way off, it's a new field and I'm also hoping to have a better understanding of system design from this.

Thanks!

Your project description is remarkably unclear.

Are you trying to drive the original sound chips at their original clock frequencies? What do they do?

What is the ATMega32U4 supposed to do?

Things you need to know:-

  1. You can get crystals made at any frequency quite cheaply, even one off quantities.
  2. You can not run an Arduino off 53.693175 MHz, the top speed for the ATmega chips is 20 MHz, and trying to bodge the zero to run at that frequency is a bit of a challenge.
  3. You can still get those chips on eBay.

given the divisions are odd numbers

  1. The fact that the divisors are an off number does not affect anything if you are willing to put up with a rectangular wave. If not the you can use a Phased Locked Loop ( PLL ) to get a square or sin wave from any divisor odd or even.

jremington: Your project description is remarkably unclear.

Are you trying to drive the original sound chips at their original clock frequencies? What do they do?

What is the ATMega32U4 supposed to do?

Im sorry, I thought I did make my self fairly clear. Yes I need them at the original frequencies. Their purpose is to make sound. - Edit: Sorry, AS making me think you asked a different question. The idea is to mostly replicate the console's sound system, just allow me to control it by connecting up to PCs, MIDI or using a front panel IO. Thats the base needs, I can learn to do the rest.

I'm trying to follow the original sound system design to keep it accurate to the console and I guess I had it in my mind that having independent clocks could offset something? (idk)

Grumpy_Mike: Things you need to know:- 1) You can get crystals made at any frequency quite cheaply, even one off quantities. 2) You can not run an Arduino off 53.693175 MHz, the top speed for the ATmega chips is 20 MHz, and trying to bodge the zero to run at that frequency is a bit of a challenge. 3) You can still get those chips on eBay. 4) The fact that the divisors are an off number does not affect anything if you are willing to put up with a rectangular wave. If not the you can use a Phased Locked Loop ( PLL ) to get a square or sin wave from any divisor odd or even.

I didn't plan to run the Atmega off of the 53MHz clock, I rather meant to say about doing a devision to 16~ mhz. Sorry.

Im using the chips from a dead console since they were to hand (wouldn't have started if that werent the case).

I don't mind the idea of a PLL (despite having no knowledge on them or using them) and using a square wave is fine.

the latter at a slower 3.579545 MHz

This is the TV "color burst" frequency and those crystals are everywhere. Double that for a reasonable approximation to 7.67 MHz.

jremington: This is the TV "color burst" frequency and those crystals are everywhere. Double that for a reasonable approximation to 7.67 MHz.

That's a good point. So in this case I could just double the 76489 clock using simple logic and get a good approximation and they'd both be in sync.

Another thought that occured to me on a similar subject. The two sound ICs are being controlled by the 32u4 which would run on it's own clock. Originally the console had a Z80 CPU running at the same clock speed as the 76489 (the YM being doubled as mentioned previously). Given the sound system used to be "in sync" with the CPU, would running the Atmega on it's on clock be a problem when writing commands?

Unless you really understand the original hardware design, there is no point in making assumptions about whether clocks need to be in sync.

I would think not, considering how slowly audio signals change. However, do check the data sheets of the original chips for the timing requirements.

Fair point, cheers for the advice :)

Been working on this again and after doing a few experiments, the previously mentioned double the 3.5MHz clock wouldn’t work for me unfortunately. Turns out that the YM2612 would just be running too slow for my purpose, even if only 511KHz slower, it’s severely noticable and drops all notes down by roughly half a semitone.

Whilst I could adapt the MIDI in signals by making them step down a semitone but this seems like a hacky solution plus another thing I would like it to do (play real songs, say from emulators, in realtime from the USB serial of the 32u4) would mean ensuring compatibility with that.

With that all said, I found I can get a 7.68MHz crystal which is about 0.124% difference and even to my ears I can’t tell a difference. The only annoyance with using separate crystals is that I couldn’t really control it (unless there is a way); this would mean the real time playback would only work at the consoles NTSC speeds. I guess this isnt a problem, just annoying as I would have liked to change between the two “regions”.