Jump to content
IGNORED

Arduino to TIA Help


johnnye79

Recommended Posts

I need some noob help, ripping my hair out.

I'm trying to program the TIA's sound from an Arduino and don't seem to be getting anything from AUD1 or AUD2. Also my READY bit is always 0.

 

On my Arduino I set pins 2-7 to TIA pins D0-D5, and pins A0-A5 to TIA pins A0-A5 respectively (I am writing with digitalWrite on those analog pins from the Arduino, and getting 5V as expected on the right address pins from my Voltmeter).

I have a 3.5Mhz Crystal Oscillator hooked up to OSC on the TIA, 5V/GND to VCC/VSS.

I set R/W to 0, set CSYNC to 1, write my address/data and set CSYNC to 0.

 

So far no luck, am I missing something?

 

(I'm not at all concerned with the TIA's graphics or inputs, just the sound, but should I be doing anything on other pins? Do I need to do anything with Phi-0 and Phi-2?)

 

I've seen some Youtube vids with people circuit bending with the TIA, but haven't seen any specific How To's on the topic, just what I've read from the Stella Programming Guide.

 

This is my Arduino Sketch just for reference. I used delays rather than waiting on Ready (I know, bad bad bad), but I put in fairly long delays just to test things out, long enough to give lots of cycles.

const unsigned char Sound[2] = {0x15,0x16}; // 4-bit D3-D0: 0 = voice 1, 1111 = voice 16
const unsigned char Freq[2] = {0x17,0x18}; // 5-bit D4-D0: 0 = no division, 11111 = divide by 32
const unsigned char Vol[2] = {0x19,0x1A}; // 4-bit D3-D0: 0 = no output, 1111 = highest

// Set RW to Low
// Set CS high then low to strobe

const int Ready = 10;
const int ClockSync = 11;
const int ReadWrite = 12;

void setup() {
  Serial.begin(9600);
  delay(500);
  Serial.println("Initializing...");
  // put your setup code here, to run once:

  // data bus pins
  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);

  // address pins (set digital)
  pinMode(A0,OUTPUT);
  pinMode(A1,OUTPUT);
  pinMode(A2,OUTPUT);
  pinMode(A3,OUTPUT);
  pinMode(A4,OUTPUT);
  pinMode(A5,OUTPUT);

  pinMode(Ready, INPUT);
  pinMode(ReadWrite, OUTPUT);
  pinMode(ClockSync, OUTPUT);

  initAtari();

  Serial.println("Write to Channel 0...");
  AtariWriteTone(0,15,14,2);
  Serial.println("Write to Channel 1...");
  AtariWriteTone(1,15,14,2);
}

void initAtari() {
  digitalWrite(ReadWrite, 0); 
  digitalWrite(ClockSync, 1); 
  delay(100);
}

void AtariWriteTone(int chan, unsigned char volume, unsigned char freq, unsigned char sound) {
  digitalWrite(ClockSync, 1); 
  delay(200);
  writeAddressByte(Sound[chan]);
  writeByteToDataBus(sound);
  digitalWrite(ClockSync, 0); 
  delay(200);

  digitalWrite(ClockSync, 1); 
  delay(200);
  writeAddressByte(Freq[chan]);
  writeByteToDataBus(freq);
  digitalWrite(ClockSync, 0); 
  delay(200);

  digitalWrite(ClockSync, 1); 
  delay(200);
  writeAddressByte(Vol[chan]);
  writeByteToDataBus(volume);
  digitalWrite(ClockSync, 0); 
  delay(200);
}

void writeAddressByte(unsigned char data) {
  int b0 = data & 1;
  int b1 = (data >> 1) & 1;
  int b2 = (data >> 2) & 1;
  int b3 = (data >> 3) & 1;
  int b4 = (data >> 4) & 1;
  int b5 = (data >> 5) & 1;

  digitalWrite(A0,b0);
  digitalWrite(A1,b1);
  digitalWrite(A2,b2);
  digitalWrite(A3,b3);
  digitalWrite(A4,b4);
  digitalWrite(A5,b5);
}

void writeByteToDataBus(unsigned char data) {
  int b0 = data & 1;
  int b1 = (data >> 1) & 1;
  int b2 = (data >> 2) & 1;
  int b3 = (data >> 3) & 1;
  int b4 = (data >> 4) & 1;
  int b5 = (data >> 5) & 1;

  digitalWrite(2,b0);
  digitalWrite(3,b1);
  digitalWrite(4,b2);
  digitalWrite(5,b3);
  digitalWrite(6,b4);
  digitalWrite(7,b5);

}



void loop() {
  // put your main code here, to run repeatedly:
  int rdy = digitalRead(Ready);
  Serial.println("Ready: " + String(rdy));
  delay(1000);
}
Link to comment
Share on other sites

I'm trying to program the TIA's sound from an Arduino and don't seem to be getting anything from AUD1 or AUD2.

TIA outputs are open-collector, so you need to put pullup resistors in order to make them work.

post-10599-0-00147300-1473923387_thumb.jpg

Also my READY bit is always 0

READY (pin 3) is an output used to halt the 6502 until the end of a scanline when the TIA WSYNC register is strobed. Since you're not using the graphics, you probably don't need it in this application.

 

I set R/W to 0, set CSYNC to 1, write my address/data and set CSYNC to 0.

CSYNC (pin 2) is an output! It's the Composite SYNC for the video signal.

 

There are 4 CHIP SELECT inputs on the TIA: 3 active-low (pin 21, 22 and 24) and 1 active-high (pin 23). These must be set correctly before accessing the TIA.

post-10599-0-34843800-1473946754_thumb.png

EDIT: the picture I was using as reference had 2 of the CS pin active state swapped. I fixed both the picture and the post

 

(I'm not at all concerned with the TIA's graphics or inputs, just the sound, but should I be doing anything on other pins? Do I need to do anything with Phi-0 and Phi-2?)

Phi0 (pin 4) is an output and it's the clock divided by 3, used as the main clock for the 6502 inside the 2600 console.

 

Phi2 (pin 26) is an input and it's the phase-2 clock (generated by the 6502 in the 2600). This is used by the TIA to know when valid data can be read/output on the bus, so I'm pretty sure you'll need it to make it work.

 

Take a look at the timing charts in the Stella Programmer's Guide and in the 650x processor datasheet.

 

I'd suggest to open a thread in the "hardware" section here on AA, where it's more likely that the electronics experts will see it.

Edited by alex_79
Link to comment
Share on other sites

TIA outputs are open-collector, so you need to put pullup resistors in order to make them work.

attachicon.giftia_pullups.jpg

READY (pin 3) is an output used to halt the 6502 until the end of a scanline when the TIA WSYNC register is strobed. Since you're not using the graphics, you probably don't need it in this application.

 

CSYNC (pin 2) is an output! It's the Composite SYNC for the video signal.

 

There are 4 CHIP SELECT inputs on the TIA: 3 active-low (pin 21, 22 and 24) and 1 active-high (pin 23). These must be set correctly before accessing the TIA.

attachicon.giftia_ntsc.png

EDIT: the picture I was using as reference had 2 of the CS pin active state swapped. I fixed both the picture and the post

 

Phi0 (pin 4) is an output and it's the clock divided by 3, used as the main clock for the 6502 inside the 2600 console.

 

Phi2 (pin 26) is an input and it's the phase-2 clock (generated by the 6502 in the 2600). This is used by the TIA to know when valid data can be read/output on the bus, so I'm pretty sure you'll need it to make it work.

 

Take a look at the timing charts in the Stella Programmer's Guide and in the 650x processor datasheet.

 

I'd suggest to open a thread in the "hardware" section here on AA, where it's more likely that the electronics experts will see it.

 

Thanks for the info. I got confused in the Stella docs where it says "when the 02 clock goes high to low" in the Data Addressing section, I thought meant Pin 2. :P

 

I've fixed it in my code now to set RW to 1, write my address/data, then set RW to 0. I've added some Pullup resistors to AUD1/AUD2.

 

Still getting nothing out of the device though (I should add that my speakers also have an internal amp on them, and work very well with my SN76489ANs).

 

I took a look at the timings in the docs. I'm not sure what to set the 4 CS lines to if I *just* want to use the TIA standalone without the 6507/2 (since I'm using the Arduino to control the TIA). Right now they're floating until I know. Should 21/22/24 be high and 23 be low?

 

If I'm applying 5V/GND, and an Oscillated 5V to OSC, shouldn't Phi0 be showing some voltage?

My voltmeter shows 0V on 2 different TIA chips (one is out of a working 2600 Jr, and the other was delivered just this week from eBay).

 

If I'm bypassing the 6507/2, should I be able to write to Phi2 directly? e.g. Set RW to 1 and Phi2 to 0, write address/data, set RW to 0 then Phi2 to 1, as per pages 47 & 48 in the Stella programming guide.

Link to comment
Share on other sites

I took a look at the timings in the docs. I'm not sure what to set the 4 CS lines to if I *just* want to use the TIA standalone without the 6507/2 (since I'm using the Arduino to control the TIA). Right now they're floating until I know. Should 21/22/24 be high and 23 be low?

CS pins are used to allow more than one memory or I/O IC on the CPU address and data bus. On the 2600 only 2 of the TIA CS are used (/CS0 and /CS3), the other two are just tied to +5V and GND. The 7800 uses 1 more CS pin . If you don't have anything else sharing the same data and address lines with the TIA, then I guess that you can leave it always selected (that is, pin 21,22 and 24 low and 23 high.

But don't take my word for it, as this is beyond my basic skills in electronics.

 

 

Link to comment
Share on other sites

CS pins are used to allow more than one memory or I/O IC on the CPU address and data bus. On the 2600 only 2 of the TIA CS are used (/CS0 and /CS3), the other two are just tied to +5V and GND. The 7800 uses 1 more CS pin . If you don't have anything else sharing the same data and address lines with the TIA, then I guess that you can leave it always selected (that is, pin 21,22 and 24 low and 23 high.

But don't take my word for it, as this is beyond my basic skills in electronics.

 

No worries, thanks for the help you could give, definitely appreciated! :)

 

I do have one question. Earlier up there is a picture with some green highlighted parts. Do you know where the full schematic of that image is? Looks like the top is cut off around the oscillator.

 

Looks very different from another schematic I saw here so I'm curious as to the design of the oscillator (right now I'm using a 3.5Mhz Crystal Oscillator, may change that to 3.579545Mhz crystal with a custom oscillator):

 

http://kevtris.org/2600/2600schemo.html

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...