dolomiah wrote:
Hi Folks, BigEd posted a question about this to me, as I am the guy on the Hackaday link above with a working 65c02 driving a 9918.
So I am not using any special wait states, clock extending etc. circuitry at all, it is not required (as alluded by aslak in the last reply). But I am only running my 6502 at 2.68Mhz at the moment, not sure it will drive the VDP reliably above this.
I don't have a schematic, but simple to describe:
- 6502 D0-D7 connected to CD7-CD0 (remembering that the bits are numbered in the opposite sense to the 6502)
- 6502 A0 connected to MODE
- For chip select, CSW and CSR remain high when the VDP is not to be selected, else R/W connected to CSW, with the inverted signal connected to CSR. To do this I have a decode which outputs Low when the VDP is addressed by the 6502, and this decode is inverted and then NANDed with the R/W and inverted W/R signals before being fed to the VDP CSW and CSR line.
This works because:
- The timing requirement for CSW is 200ns nominal. As the 6502 accesses on half cycle time, then I guess this means my total 6502 cycle time cannot be more than 400ns. This is 2.5Mhz, a little bit slower than the 2.68Mhz I am driving the 6502 at - but not sure whether the term 'nominal' means that CSW could be pulse low for a significantly shorter time.
- The timing requirement for CSR is that data becomes valid no more then 150ns after CSR is low. This is a shorter half cycle than CSR, potentially means 6502 access could be faster for read rather than write.
So the manual then has some words about 2us to 8us cycle time. I think this is misleading because I believe the VDP works as follows:
- the VDP must internally latch the access based on MODE, CSR, CSW and latch any input data present on CD7-CD0
- the VDP then takes between 2us and 8us to perform its internal operations to set or read VRAM
- additionally, the VDP must be reading the first byte in readiness when it is provided a VRAM address to start reading from
Therefore, what is needed is that between 6502 accesses, one needs to wait between 2us and 8us (depending on the screen mode). I just use a bunch of NOPs.
Here's why I think the internal operation works as above. When I was first trying to get the VDP to work, I didn't have enough NOPs. The operation of the VDP is that one can send the VRAM address and then do successive reads or writes which auto increments the address pointer. When I didn't have enough NOPs, I would end up writing to the same VRAM address (which I could tell because my font initialisation was sometimes creating odd looking characters). When reading too fast, the VDP just gives the last successfully read VRAM byte on CD7-0.
There is nothing of note to show in the code. Basically to read a byte, I use LDA MODE0 followed by 5 NOPs. Then I can do another read and the VDP will give me the next byte.
I still don't know the difference between a nominal and a minimum timing requirement, and whilst I think a 6502 at significantly more than 2.5Mhz will be too fast to interface directly, I haven't tried it - but one of my thoughts is to try and drive around 4Mhz to see what occurs (but I can't do this yet as have other things to upgrade which won't work at that speed).
I hope that helps - ask away if I haven't made sense!
Cheers, Dolo
Hi,
>There is nothing of note to show in the code. Basically to read a byte, I use LDA MODE0 followed by 5 NOPs. Then I can do another read and the VDP will give me the next byte.
My main question is: When do another read, after setting up the initial address, do you have bring up /CSR to HIGH then LOW again to do another read? Same for write but with /CSW? Then same thing for writing a value to like REGISTER one. First the data byte then another byte to identify the register. So I pause (via NOP instructions) between writing the first and 2nd byte?
The TMS9918 is so screwed up with switching around the MSB and LSB!
Thanks!