Has anyone successfully interfaced this IC?
If so, would you please elaborate on the process? That is, is the address first sent, then the data?
Thank you,
TomC
Has anyone successfully interfaced this IC?
If so, would you please elaborate on the process? That is, is the address first sent, then the data?
Thank you,
TomC
I have. Yes, you write the address first. The A0 line on the YMZ284 is the key.
For every byte written to the YMZ284:
This is the minimal setup. For quieter operation you might want to use the /WR (enable = LOW) also.
Here is some sample code that includes wiring notes:
/* Yamaha YMZ284-D Test 1
Pin connections between Arduino and YMZ384
Arduino YMZ284
Data
9 16
8 15
7 14
6 13
5 12
4 11
3 10
2 9
Control
10 3
11 1
Pin 7 (clock) of YMZ284 connected to OUT pin of 1MHz oscillator
Pin 5 (SO) of YMZ284 connected to audio jack
Pin 4 of YMZ284 goes to +5V
Pin 6 of YMZ284 is ground
Pin 8 (IC/) of YMZ284 is set to ground (LOW)
*/
// The YMZ284 data pins mapped to Arduino pins
#define D0 9
#define D1 8
#define D2 7
#define D3 6
#define D4 5
#define D5 4
#define D6 3
#define D7 2
// address/data mode line AO
#define AO 10
// some Addresses
// $00, $01 Channel A Frequency
// $02, $03 Channel B Frequency
// $04, $05 Channel C Frequency
// $06 Noise Frequency
// $07 Mixer Setting
// $08 Channel A level
// $09 Channel B level
// $0A Channel B level
// $0B, $0C Envelope Frequency
// $0D Envelope shape
// $0F Control power
// Register Array
#define frequencyAfine 0
#define frequencyAcourse 1
#define frequencyBfine 2
#define frequencyBcourse 3
#define frequencyCfine 4
#define frequencyCcourse 5
#define noiseFrequency 6
#define mixerSetting 7
#define levelA 8
#define levelB 9
#define levelC 10
#define envelopeFrequencyFine 11
#define envelopeFrequencyCourse 12
#define envelopeShape 13
int f=0;
int e=0;
int freq;
int dly=300;
void setup()
{
int i;
for (i = 2; i < 10; i = i+1) {
pinMode(i, OUTPUT);
}
pinMode(A0, OUTPUT);
digitalWrite(A0, LOW);
pinMode(13, OUTPUT);
randomSeed(analogRead(0));
Serial.begin(9600);
}
void loop()
{
// set the Envelope Frequency
writeAddress(envelopeFrequencyFine);
writeData(B11111111);
writeAddress(envelopeFrequencyCourse);
writeData(B00000001);
// select the volume register for channel A & set to
// envelope controlled
writeAddress(levelA);
writeData(B00010000);
// select the volume register for channel B & set to high
writeAddress(levelB);
writeData(B00010000);
// select the volume register for channel C & set to high
writeAddress(levelC);
writeData(B00001111);
// set the mixer setting to mask out noise
writeAddress(mixerSetting);
writeData(B00111000);
// Choose a random envelope shape
writeAddress(envelopeShape);
e = random(15);
Serial.print("Envelope: ");
Serial.println(e);
writeData(e);
Serial.println("Now the fine tuning...");
// cycle from 1 to 255 for fine frequency
for (int i=1; i <= 15; i++) {
// select the course register for channel A
freq = i * 16;
writeAddress(frequencyAfine);
writeData(freq);
writeAddress(frequencyBfine);
writeData(freq);
writeAddress(frequencyCfine);
writeData(freq);
f = 1048576/(32*freq);
Serial.println(f);
delay(dly);
}
Serial.println("Now the course tuning...");
// cycle 0 to 15 for course tune frequency
for (int i=1; i < 3; i++) {
// select the course register for channel A
freq = 2 * i;
writeAddress(frequencyAcourse);
writeData(freq);
writeAddress(frequencyBcourse);
writeData(freq);
writeAddress(frequencyCcourse);
writeData(freq);
f = 1048576/((25632freq) + 255);
Serial.println(f);
delay(dly * 2);
}
Serial.println("Cleaning up...");
// clean up course registers
writeAddress(frequencyAcourse);
writeData(0);
writeAddress(frequencyBcourse);
writeData(0);
writeAddress(frequencyCcourse);
writeData(0);
delay(dly);
}
void writeAddress(byte b) {
//delay(10);
// setup for address write mode
digitalWrite(A0, LOW);
// write the address
writeByte(b);
}
void writeData(byte b) {
// setup for address write mode
digitalWrite(A0, HIGH);
// write the data
writeByte(b);
}
void writeByte(byte b) {
// set all data pins to 0
int i;
for (int i=2; i < 10; i++) {
digitalWrite(i, LOW);
}
// convert byte value to data pins on YMZ284
byte t;
t = b & B00000001;
if ( t == B00000001) {
digitalWrite(D0, HIGH);
}
t = b & B00000010;
if ( t == B00000010) {
digitalWrite(D1, HIGH);
}
t = b & B00000100;
if ( t == B00000100) {
digitalWrite(D2, HIGH);
}
t = b & B00001000;
if ( t == B00001000) {
digitalWrite(D3, HIGH);
}
t = b & B00010000;
if ( t == B00010000) {
digitalWrite(D4, HIGH);
}
t = b & B00100000;
if ( t == B00100000) {
digitalWrite(D5, HIGH);
}
t = b & B01000000;
if ( t == B01000000) {
digitalWrite(D6, HIGH);
}
t = b & B10000000;
if ( t == B10000000) {
digitalWrite(D7, HIGH);
}
}