0
\$\begingroup\$

I have hooked up an AY-3-8910 sound chip to an Arduino Nano and I am trying to get it to give me a square wave at a frequency of 440Hz on channel A. The datasheet for the AY-3-8910 says that the frequency of the tone generator is obtained by first dividing the input clock (2 MHz in my case) by 16 and then dividing the result by the 12 bit tone period value, but I can't work out how to calculate the values for a desired freqeuncy to store in the coarse tune and fine tune registers. The 12 bit value is made up by combining the two 8 bit coarse tune and fine tune registers. Can anyone help? Thanks.

\$\endgroup\$
7
  • \$\begingroup\$ Please link to a data sheet and list the page that mentions dividing the input clock by 16 then dividing by the 12 bit tone period value. \$\endgroup\$
    – Andy aka
    Aug 30 at 14:57
  • \$\begingroup\$ The datasheet is here: colecovision.dk/PDF/ay-3-8910.pdf Page 5. \$\endgroup\$ Aug 30 at 14:58
  • \$\begingroup\$ I think you might mean page 4. Can't you find a data sheet more modern than that one? \$\endgroup\$
    – Andy aka
    Aug 30 at 15:01
  • \$\begingroup\$ @Andy Its an old chip. It is getting on for 35 years old. \$\endgroup\$ Aug 30 at 15:02
  • \$\begingroup\$ a quick search result atariage.com/forums/… \$\endgroup\$ Aug 30 at 15:21
2
\$\begingroup\$

The formula is as described in the datasheet. The master clock is divided by 16, and divided by the tone period register value to get the tone frequency.

Thus, to calculate the tone period value from the frequency you want, 440 Hz is calculated as follows : (2 MHz / 16) / 440 Hz = 284 in decimal, or 0x011C in hex.

The tone period register is 12-bit so it is divided into high 4 bit part and low 8-bit part. Thus the two register values are 0x01 for the high register and 0x1C for the low register.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.