Use of RDY pin for a VERY slow device
Use of RDY pin for a VERY slow device
Hi,
Just for fun, I'm trying to program a micro controller (arduino MEGA) to emulate the RAM/ROM memory that a 65C02 will need to run. The micro controller is connected to all pins of the 6502 except power, emulating RAM and ROM where needed.
My problem is that the microcontroller is way too slow to behave as a real RAM/ROM chip. Also, I would like to microprocessor to run as slow as I want.
Right now, I have the 65C02 free running and performing RES and NMI, clock is generated by the arduino and pins state output using serial port.
My problem now is: when the 6502 gives a low in R/W pin, the microcontroller should configure the data bus pins as inputs before the 6502 outputs data.
Can I set RDY to LOW, read RW and address pins, prepare the data bus for read or write, then set DRY to HIGH for (say) 1us ? How can this be done ?
I fear to damage the microprocessor if both devices try to write to data bus simultaneously.
Thanks so much !
Just for fun, I'm trying to program a micro controller (arduino MEGA) to emulate the RAM/ROM memory that a 65C02 will need to run. The micro controller is connected to all pins of the 6502 except power, emulating RAM and ROM where needed.
My problem is that the microcontroller is way too slow to behave as a real RAM/ROM chip. Also, I would like to microprocessor to run as slow as I want.
Right now, I have the 65C02 free running and performing RES and NMI, clock is generated by the arduino and pins state output using serial port.
My problem now is: when the 6502 gives a low in R/W pin, the microcontroller should configure the data bus pins as inputs before the 6502 outputs data.
Can I set RDY to LOW, read RW and address pins, prepare the data bus for read or write, then set DRY to HIGH for (say) 1us ? How can this be done ?
I fear to damage the microprocessor if both devices try to write to data bus simultaneously.
Thanks so much !
Re: Use of RDY pin for a VERY slow device
If you're generating your phi2 clock by way of the Arduino, and are using a WDC 'c02, then don't worry overmuch about the timing, don't bother with RDY, just have the clock pin transition only when your data bus pins are in the appropriate state.
Doing this with an '816 could be trickier, to the point where you might want to include the full bank-latch circuit.
Doing this with an '816 could be trickier, to the point where you might want to include the full bank-latch circuit.
Re: Use of RDY pin for a VERY slow device
Yes, I'm generating clock in (pin 37) with the Arduino.
But my 65C02 doesn't seem to be the WDC. I just tried setting LOW or HIGH pin 36 (BE in the WDC) and it doesn't make any difference, so I guess it isn't connected and therefore it is not the WDC.
What is a '816 ?
But my 65C02 doesn't seem to be the WDC. I just tried setting LOW or HIGH pin 36 (BE in the WDC) and it doesn't make any difference, so I guess it isn't connected and therefore it is not the WDC.
What is a '816 ?
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Use of RDY pin for a VERY slow device
Quote:
What is a '816 ?
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: Use of RDY pin for a VERY slow device
frikosal wrote:
I fear to damage the microprocessor if both devices try to write to data bus simultaneously.
The 6502 and 65C02 never drive the data bus during the first half of each cycle -- the Phase 2 low time. It's a period of guaranteed inactivity. Therefore the Arduino can examine the R/W pin during this time and learn in advance whether the last half of the cycle will belong to the Arduino or to the 65c02. Then after the last half is complete we return to another period of guaranteed inactivity.
To control timing you can just let the Arduino supply the input clock to the 65c02, as nyef suggested. IOW don't bother using RDY; just tie it high. This will allow you to run one cycle at a time, as slowly as you wish. Just be sure to stop the clock in the high state, not the low state. That's because with some 65c02s such as Rockwell the maximum duration of the low state is limited. But the limit is very generous -- listed as 5000 ns (ie; five milliseconds ) for Rockwell, and even that large figure is probably very conservative. IOW there's plenty of time for the Arduino to set the stage before it raises the clock line to the 65c02 for the 2nd half of the cycle.
GARTHWILSON wrote:
Newcomers tend to shy away from [the 65c816]; but I would say it's not nearly as complicated as people make it out to be.
-- Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
https://laughtonelectronics.com/Arcana/ ... mmary.html
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Use of RDY pin for a VERY slow device
frikosal wrote:
Yes, I'm generating clock in (pin 37) with the Arduino.
But my 65C02 doesn't seem to be the WDC. I just tried setting LOW or HIGH pin 36 (BE in the WDC) and it doesn't make any difference, so I guess it isn't connected and therefore it is not the WDC.
But my 65C02 doesn't seem to be the WDC. I just tried setting LOW or HIGH pin 36 (BE in the WDC) and it doesn't make any difference, so I guess it isn't connected and therefore it is not the WDC.
When negated, BE brings the MPU's bus and RWB outputs to the high impedance state. Negating BE does not stop the MPU.
When negated, RDY stops the MPU in the Ø2 high state. Negating RDY does not bring the MPU's bus and RWB outputs to the high impedance state, that is, the buses continue to be driven by the MPU if the current cycle is a write cycle.
The usual procedure for interfacing a slow device to the 65C02 is to generate one or more wait-states when that device is selected. The glue logic watches for when the device is selected and when it is, negates RDY for at least one full Ø2 cycle. The 65C02 stops but keeps the buses and RWB in the state that they would be in if RDY were not negated. This gives the slow device time to recognize all relevant signals and react as required. After the wait-state has expired, RDY is released and the 65C02 restarts on the next rise of Ø2.
Since you are attempting to make the Arduino act like a ROM, you need to put it under the control of the MPU, not the other way around.
Quote:
What is a '816 ?
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: Use of RDY pin for a VERY slow device
Hi guys !!!
It seems it is working, thanks a lot !!!!
I ignored RDY pin and generate clock signals not at constant frequency but when Arduino is ready to do the next operation.
I'm not sure it is correct but it runs a loop with INX, STX in zero page and JMP. Can you see this screen capture ?
https://dl.dropboxusercontent.com/u/249 ... system.png
Later I'll go on trying more complex instructions, I'll also try to capture the signals with my logic analyser
But right now I have to avoid serious familiar problems
It seems it is working, thanks a lot !!!!
I ignored RDY pin and generate clock signals not at constant frequency but when Arduino is ready to do the next operation.
I'm not sure it is correct but it runs a loop with INX, STX in zero page and JMP. Can you see this screen capture ?
https://dl.dropboxusercontent.com/u/249 ... system.png
Later I'll go on trying more complex instructions, I'll also try to capture the signals with my logic analyser
But right now I have to avoid serious familiar problems
Re: Use of RDY pin for a VERY slow device
Here is my setup as it is now. Yesterday I was having erratic problems so I decided to weld the wires between the Arduino and the Arduino Mega. At the right hand side, the data and address busses. The mega has more than enough IO ports to control all the pins of the 6502 plus a display. Unfortunately, I'm doing something wrong, the 6502 starts doing weird things after some instructions. Lets see if next weekend I can fix it...
https://dl.dropboxusercontent.com/u/249 ... 203403.jpg
https://dl.dropboxusercontent.com/u/249 ... 203403.jpg
Re: Use of RDY pin for a VERY slow device
frikosal wrote:
the 6502 starts doing weird things after some instructions.
Also regarding the matter of the supply, I suggest you verify the voltage by measuring right at the 65c02 chip. This is just good basic troubleshooting. Another issue -- more of a design question -- is providing a supply bypass capacitor close to the 65c02. In the photo I can't see whether you've taken care of that.
cheers,
Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
https://laughtonelectronics.com/Arcana/ ... mmary.html
Re: Use of RDY pin for a VERY slow device
frikosal wrote:
Here is my setup as it is now. Yesterday I was having erratic problems so I decided to weld the wires between the Arduino and the Arduino Mega. At the right hand side, the data and address busses. The mega has more than enough IO ports to control all the pins of the 6502 plus a display. Unfortunately, I'm doing something wrong, the 6502 starts doing weird things after some instructions. Lets see if next weekend I can fix it...
https://dl.dropboxusercontent.com/u/249 ... 203403.jpg
https://dl.dropboxusercontent.com/u/249 ... 203403.jpg
Re: Use of RDY pin for a VERY slow device
Dr Jefyll wrote:
frikosal wrote:
the 6502 starts doing weird things after some instructions.
Re: Use of RDY pin for a VERY slow device
LIV2 wrote:
I believe AVR/MEGA based Arduinos all operate at 5V while the ARM based boards operate at 3.3v so this shouldn't be an issue for him
I'd still like to know what kind of 65c02 frikosal is using, and whether it has a supply bypass capacitor connected close by.
-- Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
https://laughtonelectronics.com/Arcana/ ... mmary.html
Re: Use of RDY pin for a VERY slow device
Hi guys,
I'm using a Rockwell 65c02, or so it seems according to its logo. I bought it on Ebay so who knowns.. Just ordered what seems a WD.
I'm powering it, as well as the arduino, from the USB.
No, I'm not using the capacitor. Can you please suggest me the capacitor to use ?
Before welding it, it could run a single loop. I implemented a 8 digits 7 segments LED display. It was red, to look like a KIM 1
Arduino copied the contents of adresses 0x300 to 0x303 to the display, so it could see it running. It was cute !!
I also wrote a small program to transfer the xa output to the Arduino. It can save 4kb in its own internal eeprom.
Now I'm using a small PCB to bring the Arduino 24 lines to the Adafruit permaproto board where the 6502 is.
Choosing carefully the Mega pins, you can write data bus with a single instruction and address bus with two instructions, bypassing the very slow arduino libraries.
My final goal would be to have a Mega shield (a PCB on top of the Mega) with the 6502, a display and some keys.
That would be single chip 6502 system
It would be very nice to design a PCB and order it, with a 2 layers it should be enough.
This can be very interesting to experiment with the 6502, also to attract young people from the Arduino community to our beloved 6502.
What do you think ?
Manel
I'm using a Rockwell 65c02, or so it seems according to its logo. I bought it on Ebay so who knowns.. Just ordered what seems a WD.
I'm powering it, as well as the arduino, from the USB.
No, I'm not using the capacitor. Can you please suggest me the capacitor to use ?
Before welding it, it could run a single loop. I implemented a 8 digits 7 segments LED display. It was red, to look like a KIM 1
Arduino copied the contents of adresses 0x300 to 0x303 to the display, so it could see it running. It was cute !!
I also wrote a small program to transfer the xa output to the Arduino. It can save 4kb in its own internal eeprom.
Now I'm using a small PCB to bring the Arduino 24 lines to the Adafruit permaproto board where the 6502 is.
Choosing carefully the Mega pins, you can write data bus with a single instruction and address bus with two instructions, bypassing the very slow arduino libraries.
My final goal would be to have a Mega shield (a PCB on top of the Mega) with the 6502, a display and some keys.
That would be single chip 6502 system
It would be very nice to design a PCB and order it, with a 2 layers it should be enough.
This can be very interesting to experiment with the 6502, also to attract young people from the Arduino community to our beloved 6502.
What do you think ?
Manel