On Thu, 2 Jan 2003, Dwight K. Elvey wrote:
I'm
trying to troubleshoot a more pressing problem right now: the reader
is picking 5 cards before the Apple thinks 80 Index Marks (e.g. 80
characters) have been detected. Either my code is wrong, my code is slow,
or the Apple is too slow to handle the reader input (in which case this
was all for naught).
It sounds like something is wrong. Are you reading with BASIC
or at code level. I would think that assembly code should be able
to keep up, as long as you were not expecting it to transfer to
disk while reading. Does the M200 have any kind of handshake?
I'm not so sure. Here's what I know:
6502 operates at roughly 1,000,000 cycles per second.
I wrote a very tight code loop to simply look for the READY signal from
the reader, and then count Index Marks, as quickly as it can. Here's the
relevant loop code (the number is parentheses at the end of the comment
is the number of cycles that instruction takes):
LDX #$00
LOOP LDA $C0C1 ; Get the data at 6522 Port A (4)
AND #$08 ; Bit 4 is the RDY signal input (4)
BEQ LOOP ; Loop until it goes true (2)
WAIT LDA $C0C1 ; Now wait until it goes false (4)
AND #$08 ; (4)
BEQ WAIT ; (2)
INX ; Increment the count (2)
INC $06 ; Increment a zero page location* (6)
CPX #$50 ; 80 Index Marks yet? (4)
BNE LOOP ; No? Keeping looping (2)
* So I can view the resulting value when I reset the computer to break out
of the loop
So counting up the cycles to read the index mark, it's 10 to wait for it
to go true, 10 for it to go false, then 14 to increment a counter and go
back to the top of the loop.
The timing diagram of the M200 says that the Index Mark is pulsed for 6
microseconds. Now, if I'm computing this right, that is already less time
than it takes for the 6502 to wait for the pulse to fall back to false
from true. The 6502 takes 10 cycles, or roughly 10 microseconds, assuming
a cycle is equivalent to a microsecond.
Further, the timing diagram of the M200 shows that there are 1314
microseconds of time to read the column data, and 2014 microseconds
between Index Marks. This should be enough time for the 6502 to read and
store the data, then loop again.
This is one fast reader. But too fast for the 6502 me thinks.
Not really if you do one several possible things:
1. Generate an interrupt from the index mark (can the 6522/card do this?)
Or
2. Put a oneshot or flip flop on the index mark signal so its pulse can be
seen by the 6502...
~500 cycles per second is not a problem, the 6 uSec strobe is...
:(
Sellam Ismail Vintage Computer Festival
------------------------------------------------------------------------------
International Man of Intrigue and Danger
http://www.vintage.org
* Old computing resources for business and academia at
www.VintageTech.com *