banedon wrote:
While I'm here, a quick question with regard to speed? How does the 6502 deal with speed increases with respect the RAM and ROM ICs? I.e. I've increased the speed on my project from 2MHz to 10MHz and this is within the limits allowed by the CPU and VIA (both WDC parts with a max of 14MHz). I assume that the RAM and ROM are accessed at an appropriately increased speed? If so, this may explain why I was having trouble at 10MHz: I was at random times having rubbish appear on my LCD. As soon as I swapped the RAM (an HY62256B LLP-70) for a Toshiba TC55257DPL-70L it was fine. I.e. although they both run at the same speed, the Toshiba part is coping with the faster access than the HY62256B as it's getting borderline out of spec (too slow for what's needed)?
It sounds as though you may be violating the timing of your RAM and ROM.
The -70 in their part numbers refers to the maximum guaranteed time in nanoseconds in which they will respond to selection and read- or write-enable without error. This number is a guarantee, but oftentimes parts will be faster than advertised. However, you cannot bank on this being the case. Performance will also be affected by operating temperature and voltage, as well as slight differences in the die, which explains why one RAM works okay and the other doesn't.
The key to understanding why your machine occasionally produces "rubbish" (I like that term in a computer context
) on the display is in comparing the RAM's guaranteed performance to the machine cycle time. At 10 MHz, the machine cycle time is 100ns. However, the actual time in which it is possible for the 65C02 to access a device is less than that, as can be seen by studying the MPU's timing diagram. Also a factor is the propagation delay caused by the glue logic and by parasitic capacitance and lead inductance. When all is said and done, the actual time during which the RAM has been selected and can be reliably read and written may be less than that 70ns rating, causing random errors.
In designing your circuit with a specific speed in mind, you have to analyze the timing of the slowest device on the bus (usually a ROM) and compare it to the time that will elapse from when the MPU presents a valid address and RWB state until the appropriate chip select has been asserted and an appropriate read or write signals is applied to the addressed device. You then add to that time the amount of time the addressed device will take to react to the chip select and the read or write signal—response to chip select is usually a bit slower than response to an /RD or /WD signal. If that sum exceeds the device's rating you will be violating its timing and can expect errors.
With a 65C02 (or 65C816), the data bus is not guaranteed to be "valid" until the rise of Ø2, which means that the time in which the addressed device will see usable data during a write cycle will be one-half a machine cycle, or 50ns at 10 MHz. Similarly, during a read cycle the 65C02 samples the data bus at the fall of Ø2, which means the addressed device has to be sure it is driving the data bus before the fall of Ø2.
Succinctly stated, setup should be initiated as early as possible during Ø2 low so that as much of Ø2 high as possible can be used to read or write. If the device cannot respond before the next fall of Ø2, errors are likely, producing "rubbish" on the display, among other things.