0
\$\begingroup\$

I'm building a small VGM audio player.

I currently have a SN76489 (here) that is clocked from a 3.579 crystal oscillator.

When I first power on the circuit, the SN76489 can have any random value which causes a really annoying tone/buzz until the Arduino Micro (here) powers up and starts running my code.

I know some of that is the bootloader in the Micro and when I put a permanent microcontroller in some of that may go away. But I still want the SN76489 to be immediately silent at power-on.

So I thought I would connect an output pin on the Arduino as the VCC for the crystal.

Works great.

BTW, even tying the SN76489 CE to HIGH at startup and switching it to GND doesn't work. Whatever was left on the chip is what plays.

Anyway, before I did that I measured the current for both the oscillator and the SN76489 to see which draws the lesser amount. The Arduino says it can provide 40mA per output pin. For the SN76489 my multimeter said 1.2mA and the oscillator said 0.72mA.

Now even though the Arduino is providing VCC to the oscillator, the multimeter is now displaying 1.87mA.

Why would it now draw more current when connected to the 5v OUT of the Arduino?

And, does this seem like a smart way to do this or is it not wise to power small devices like this?

Thanks!

\$\endgroup\$
1
  • \$\begingroup\$ For your measurements, it is important to know what you are measuring and what the circuit looks like. \$\endgroup\$
    – jippie
    Mar 30, 2014 at 8:06

2 Answers 2

3
\$\begingroup\$

Powering a chip / crystal oscillator from an IO-pin is not a good practice when there may be signals on other pins. This may cause the chip to latch up and possibly even self destruct. Always ensure a chip has power before it sees any signals on it's inputs/outputs.

You may get away by using a GPIO pin to mute the output using a transistor. It would require a bit of experimenting with exact values, but it basically works as follows:

  • Add a series resistor to the sound generator output
  • Add a transistor that can pull the sound generator output with the series resistor to ground.
  • Drive the transistor from a digital GPIO pin. Wire it up in such a way that it defaults to short to ground and only when you drive the GPIO pin from your code that it releases the audio ouput.
\$\endgroup\$
1
  • \$\begingroup\$ OMG, I'm slowly learning. Came back to this question today and I see what you're saying about the transistor. In fact, I've been reading lately that the ZX Spectrum used something similar to disable/enable pins, etc. That is really cool. Is there anything you can't do with a transistor!!! :-) Thanks \$\endgroup\$
    – cbmeeks
    Aug 23, 2014 at 15:35
4
\$\begingroup\$

Connect the clock input of the SN76489AN to OC4A or OC4B on the Arduino (pins 13 or 10). When the code on the Arduino starts up, configure the clock and pin to output a wave at the appropriate frequency.

PLLFRQ |= _BV(PLLTM1); // Enable PLL for high-speed timer 4
TCCR4A |= _BV(COM4A1) | _BV(PWM4A); // Configure OC4A for PWM operation
OCR4A = 8; // Set OC4A high for 9 cycles of a...
OCR4C = 17; // ... 18 cycle period
TCCR4B |= _BV(CS40); // Configure timer 4 for 64MHz

The code given will generate a 3.55556MHz square wave out of OC4A.

\$\endgroup\$
4
  • \$\begingroup\$ Actually I was going to ask how to generate the frequency in another post. Pin 13 on this dev board has an LED attached (and is OC4A) but running your code and plugging pin 13 to my oscilloscope, I get a 29.41 kHz square wave. But it looks pretty stable! Perhaps I just need to tweak the OCR5A/C a little? Any rate, awesome! Just need to learn how those timers work. Thanks! \$\endgroup\$
    – cbmeeks
    Mar 29, 2014 at 21:14
  • \$\begingroup\$ Check the values of TCCR4B and PLLFRQ. Those control the clock used on timer 4. \$\endgroup\$ Mar 29, 2014 at 21:15
  • \$\begingroup\$ Having a hard time finding out how to set the timer to either 3.579 or perhaps 4Mhz. But anyway...still a great response. Thanks \$\endgroup\$
    – cbmeeks
    Mar 30, 2014 at 1:21
  • \$\begingroup\$ You could change the PLL input to be the internal RC oscillator and then tune that using OSCCAL, but then you'd lose USB capability. \$\endgroup\$ Mar 30, 2014 at 1:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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