Cartridge Reader/Writer
-------------------------------------------------------------------------------
Parallel Port
available: 8 data ... 4 control ... 5 status
data
D0-D7 --> Octal latch inputs
control
/C3 --> /RESET
C2 --> SCK, transfer type
/C0 --> MOSI, transfer num
status
/S7 <-- MISO, transfer complete
S3-S6 <-- D0-D3 from data bus
----------------------
Atmel AVR MicroController
AT90s8535
avaiable: 32 I/O (in four 8 bit ports)
PortA
I/O <---> D0-D7 of data bus
PortB - low 4 bits for control
output ---> /ROM
output ---> /RD
output ---> /WR
output ---> /OE on ParallelPort Data octal latch
PortB - high 4 bits for programming and communication with PC
during programming
input SCK <--- /C0 of parallel port
input MOSI <--- C2 of parallel port
output MISO ---> /S7 of parallel port
input /SS <--- pulled low
not programming
input <--- /C0 ... transfer type: 0=WR, 1=RD
input <--- C2 ... transfer num: toggle = make transfer
output ---> /S7 ... transfer complete: toggle = transfer complete
output ---> /LE on Bank Address octal latch
PortC:PortD
output ---> Address Lines A0-A15
===============================================================================
Explanation of Communication Protocal between PC <--> Atmel AVR
-------------------------------------------------------------------------------
output of PC -
transfer type: 0=WR, 1=RD
transfer num: toggle = requests Atmel to make transfer
output of Atmel AVR -
transfer complete: toggle = tells PC that transfer is complete
-----------------------
No transfers are pending when -
'transfer num' = 'transfer complete'
Startup state of Atmel and PC expected to be -
transfer num = 0
transfer complete = 0
transfer type = don't care
A transfer sequence -
BEGIN: sequence is initiated by setting the transfer type
and toggling the transfer number.
CONTINUE: After each transfer is complete the transfer number
may be toggled again to continue the sequence.
END: To signify the end of a sequence, the transfer type is
changed, then the transfer number is toggled.
Note: No data is actually transfered during the
'signal end of sequence' handshaking.
-----------------------
Now for some examples of 'pseudo-code' for the PC to communicate
with the Atmel AVR.
Since the Atmel AVR runs about 8 instructions/usec, yet the PC can
only read/write one parallel port register per usec ... it is usually
the PC that is the limiting factor in speed.
To keep track of speed limits the following notation will be used:
* - preceeds any command that requires a parallel port register access
-----------------------
Read Command - from PC side
*set transfer type
//read as much as we want, 2 transfer = 1 byte
do X number of times -
*toggle transfer number
*read status
if 'transfer complete' bit is not correct -
go back and read status again
take low 4 bits of data from status
*toggle transfer number
*read status
if 'transfer complete' bit is not correct -
go back and read status again
take high 4 bits of data from status
//signal end of transfer
*set !transfer type
*toggle transfer number
*read status
if 'transfer complete' bit is not correct -
go back and read status again
If there are no delays ...
total time to read X bytes = (4 + 4*X) us
In reality there will be some delays.
Lets say max of 5 us/byte
with a more realistic rate of 10 us/byte.
-----------------------
Write Command - from PC side
*set transfer type
find data
//write as much as we want, 1 transfer = 1 byte
do X times
*output data
*toggle transfer number
find next data
*read status
if 'transfer complete' bit is not correct -
go back and read status again
//signal end of transfer
*set !transfer type
*toggle transfer number
*read status
if 'transfer complete' bit is not correct -
go back and read status again
If there are no delays ...
total time to write X bytes = (4 + 3*X) us
When programming the FlashChips or the CPLD, the speed at
which the Atmel can accept data will actually be limited
by the speed at which the flash memory will program.
An AMD 32Mbit says the typical programming time for one
byte is 7 us (with signals transitioning at maximum speed).
We can probably obtain an average programming rate of about
10 us/byte
-----------------------
*back to snes page*