ASCIIMath creating images

Tuesday, February 22, 2011

Arduino SIDshield initial schematic and code

This is the schematic for the Arduino SIDshield I've been working on, drawn using Eagle. This is NOT the circuit on the breadboard, since I don't have a couple of 74LS164's handy - instead, I used a pair of 74LS323's that are slightly more flexible.  They operate in a simple parallel out mode though.  Also, as mentioned in the previous post, the 1MHz clock is provided by a function generator buffered by a 74LS04.  Hence, regard this schematic as untested!

I still haven't gotten around adding the 5V-to-12V boost circuit.  I was planning on using the LT1109CZ-12 - a nice, small TO-92 packaged chip.  Unfortunately it's not easy to get, it seems.  My 6581 draws 27mA from the 12V supply, well within the limits promised bu Commodore (datasheet says 25mA typ, 40mA max).

Software

The library to drive the chip is a modification of the Spi library, reduced to the constructor and a single function.  I will add more functions later, for now all it does is take an address and data value and set the appropriate SID register.  This first version is on my website.  A simple sketch to test it:

#include <SID.h>

void setup()
{
  sid.setReg(24,15); // full volume
  sid.setReg(6,0xf0); // ADSR=0,0,15,0
  sid.setReg(1,0x1c); // set frequency to 440Hz
  sid.setReg(0,0xd6);
}

void loop()
{
  // .8s beep at 1s interval
  sid.setReg(4,17); // gate on
  delay(800);
  sid.setReg(4,16); // gate off
  delay(200);
}

Performance

The speed with which registers are written is pretty good.  I don't want to make it any shorter actually, since the chip select is not synchronized to the clock signal - so I have to make sure a few cycles happen during CS low.  The shift registers get loaded within 5us, and the CS signal is asserted for slightly less than that.  Overall the entire operation of setReg is about 15us.

More to come.
UPDATE: see here.

No comments:

Post a Comment