Hi!
fachat wrote:
To start a new thread ... the Micro-PET has a very simple SPI interface, and can boot from it.
- the Micro-PET has a very simple SPI interface included (but that only runs in mode 0 and fixed clock), it has a nice feature that reading the data register triggers another byte transfer, so while you store the byte just read, the next byte is already read from the SPI. Only if you read the "peek" register you get the data without triggering another transfer. See here
hhttps://github.com/fachat/MicroPET/blo ... LD/SPI.vhd and associated documentation
https://github.com/fachat/MicroPET/blob ... PLD/SPI.mdThis is almost the same as my SPI interface
https://github.com/dmsc/my6502/blob/master/rtl/spi.v The register definitions are at
https://github.com/dmsc/my6502/blob/mas ... es.inc#L45 , and the code to read one sector is at
https://github.com/dmsc/my6502/blob/mas ... m.asm#L190My registers are only two:
Code:
Name |Address| Description
---------+-------+-------------------------------------------------------
SPI_CTRL | $FE80 | W: SPI control register, any write stops the transaction
| | (CS goes high, bus is tristated)
SPI_STAT | | R: SPI status register:
| | Bit 7: transmission pending.
| | Bit 6: toggles each received byte available.
| | Bit 0: CS state (1 = SPI disabled, 0 = enabled).
---------+-------+-------------------------------------------------------
SPI_WRITE| $FE81 | W: SPI write, a write starts a SPI transaction, byte is
| | copied to the hold register and will transmit after
| | current one ends.
SPI_READ | | R: SPI read, reads data in the reception hold register.
| | after each byte transmitted.
-------------------------------------------------------------------------
The difference is that I only initiate a SPI read/write on a WRITE to the data hold register, I try to avoid performing operations on register reads, as the 6502 can do extra memory reads to unrelated locations, and also this allows to write and read in the same transaction (some devices need this).
The other difference is that I automatically handle CS on the first write to the data register, and the SPI is ended on a write to the control register, with the MISO and MOSI pins tri-stated so that I can write the flash while the board is running.
Quote:
- the Micro-PET boots from SPI, with a very simple schematics: on "ipl='1'" the IPL code shifts out the Flash read command and address zero, then counts 256x8 bits to be shifted in. During shift-in, the address lines are set to high (A8-18), or fed from the IPL counter (A0-7), and set to write, while the shift register output is directly fed to the databus. So the top 256 bytes are loaded into the top of RAM - from where the CPU then boots! See basically the last 60 lines of
https://github.com/fachat/MicroPET/blob ... LD/Top.vhd and some 'if's triggering on the 'ipl' signal.
So, if I have a CPLD on a board, I'll never use a parallel ROM ever again
So, the CPLD reads the first 256 bytes on boot - this is actually a very good idea. My design (as is FPGA based) simply encodes the boot ROM (from $FF00 to $FFFF) in the FPGA, and here the boot code loads the first 256 bytes of flash to address $200, searchs for a proper "boot" signature and jumps. If no signature is found, a simple serial monitor allows to interaction via the serial port.
Have Fun!