Offline
Full Member
Karma: 6
Posts: 135
Knowledge is proportional to the number of parts destroyed.
|
 |
« Reply #21 on: July 19, 2012, 12:58:58 pm » |
OK, let's see what I can help you with. I no longer have access to any 8910 chips so this is off my memory and the data sheet. Please forgive any confusion.
First, you can't assume that reading the clock in that fashion will work. The fact that you are seeing both 1's and 0's indicates that the clock is probably working.
By using the Serial.print() function, you are able to take (at most) the same number of readings per second as the baud rate divided by 10. (assuming 8 data bits, 1 start and 1 stop bit)
So 9600 baud / 10 = 960 readings per second.
And since there's some overhead processing going on, it's actually somewhat less than that.
But your clock is 1 MILLION Hertz and changes state 2 million times each second. (1 million 1's and 1 million 0's) By the time you take one reading, print it out and go back for the next reading, the clock has changed approximately 2083.333... times. (2000000 / 960)
Statisticly, if you were to measure the number of 1's and 0's over a long period, they would probably be close to equal in number. Short term, however, you may get three 1's followed by two 0's followed by four 1's followed by five 0's...
It looks random, and to a certain extent it is because you're somewhat randomly choosing when to read the clock with no idea if you are reading it at consistantly regular intervals.
My guess is it's probably OK.
Now, the PSG chip.
Double check that your grounds are common and all input pins are in the correct state.
A8 (pin 25) should be pulled HIGH ~A9 (pin 24) should be pulled low ~RESET (pin 23) should be HIGH
Yes, I know the 8910 is supposed to have internal pullup/pulldown resistors on those pins. I've never trusted them. And Section 2.3 recommends that A8 and ~A9 be tied to VCC and Ground, respectively.
(BTW, ~A9 is how I write the name of a low true signal, since I can't put a bar over the word on the computer)
A8 and ~A9 are very important, because without them the chip isn't enabled and won't accept data from the computer.
Your connections to the Arduino should be similar to Figure 11 in the data sheet, 8 data lines and 3 control. It's also possible to control the chip with only 2 control lines, see Section 2.3
Next, I would see if I could write to and read from a register. If you can't do that, there's probably something wrong either with your wiring or code.
As a test, you can also write to the I/O ports and check them for operation. Don't forget to set them for output in register R7.
You did remember to enable the tone outputs in register R7, didn't you? And set the amplitudes to a non-zero value in R10, R11 and R12? Just checking, it's easy to overlook things; there's a lot to set up just to make it go 'beep'.
Software-wise, I believe Majenko is correct. There is a possibility that the Arduino is too fast for the PSG and you might need to delay a bit after writing to the chip. The delay would go between any write operation (INTAK, DWS) and the following NACT instruction. The read and write pulses need to be at least 500 ns in length for reliable operation so you might need a delay there as well.
It would be best if you could get all the control pins to change at the same time. When I was working with these chips, everything was interfaced to an 8 bit port, written to at one stroke.
For a simple tone test, I'd try writing the following data to the chip registers:
R1: 0000 0000 R0: 0011 1110 (1000 Hz) R8: 0000 1111 (Maximum amplitude) R7: 1111 1110 (turn tone on)
For a 1 MHz clock, this should put out an approximately 1000 Hz tone at full volume on channel A.
Sorry about the delay at getting back to you, I'm working out of town and have intermittant access to a computer.
|