Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
boards:ecb:usb-fifo:start [2017/03/20 04:28]
will [Notes on Construction]
boards:ecb:usb-fifo:start [2023/02/26 07:55] (current)
will [Introduction]
Line 4: Line 4:
  
 The ECB-USB-FIFO board provides a high-speed interface for an EuroCard Bus machine to talk to a modern PC over USB. The board is based around the widely supported [[http://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT232H.pdf|FTDI FT232H chip]] operating in "245-style asynchronous FIFO" mode. To avoid the need to solder surface-mount parts the [[https://www.adafruit.com/product/2264|Adafruit FT232H Breakout]] board is used. The ECB-USB-FIFO board provides a high-speed interface for an EuroCard Bus machine to talk to a modern PC over USB. The board is based around the widely supported [[http://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT232H.pdf|FTDI FT232H chip]] operating in "245-style asynchronous FIFO" mode. To avoid the need to solder surface-mount parts the [[https://www.adafruit.com/product/2264|Adafruit FT232H Breakout]] board is used.
 +
 +On a KISS-68030 using an optimised transfer routine speeds in excess of 1MByte/sec (8Mbit/sec) can be achieved.
  
 On the PC the interface is presented as a standard USB serial interface (a "Virtual COM port" on Windows, /dev/ttyUSB* on Linux) and can be used by any application normally used with standard serial ports. Note that although it presents as a serial port, the baud rate and other serial settings configured on the Virtual COM Port are ignored, it just provides an 8-bit clean path at whatever rate you can pump data in or out of it. On the PC the interface is presented as a standard USB serial interface (a "Virtual COM port" on Windows, /dev/ttyUSB* on Linux) and can be used by any application normally used with standard serial ports. Note that although it presents as a serial port, the baud rate and other serial settings configured on the Virtual COM Port are ignored, it just provides an 8-bit clean path at whatever rate you can pump data in or out of it.
  
-The FT232H has a separate FIFO (first-in-first-out queue) for the receive and transmit directions. Each FIFO is 1KB in size. In the receive direction (PC to ECB) the operating system decides when to transmit data and can send up to 512 bytes in a single USB transferIn the transmit direction (ECB to PC) the FT232H will accumulate data until 512 bytes has been received, or some period of time (believed to be around 17ms) has passed since the last byte was queued, or when "send immediate" signal is given.+The FT232H has a separate FIFO (first-in-first-out queue) for the receive and transmit directions. Each FIFO is 1KB in size. Data is transferred to/from the FIFOs over the USB link in blocks of up to 512 bytes. A "send immediate" operation is supported which causes any queued data in the transmit FIFO to be sent over the USB link at the earliest opportunity, otherwise the FT232H may wait a short while to accumulate more data before performing transfer over the USB link.
  
 The board supports generating interrupts on either (or both) of two conditions: data waiting in receive FIFO, or space available in transmit FIFO. The interrupt can be routed to ECB lines NMI, INT, IR0–IR7. Enabling and masking of interrupts is under software control. The board supports generating interrupts on either (or both) of two conditions: data waiting in receive FIFO, or space available in transmit FIFO. The interrupt can be routed to ECB lines NMI, INT, IR0–IR7. Enabling and masking of interrupts is under software control.
  
 In addition to the 8-bit data path through the FIFO, there are two GPIO data lines (one input and one output) connected from the FT232H to the Status Register. These are not currently used but they were "free" to add to the design. To make use of them I believe you would need to use the FTDI MPSSE commands. In addition to the 8-bit data path through the FIFO, there are two GPIO data lines (one input and one output) connected from the FT232H to the Status Register. These are not currently used but they were "free" to add to the design. To make use of them I believe you would need to use the FTDI MPSSE commands.
 +
  
 ===== ECB I/O Registers ===== ===== ECB I/O Registers =====
Line 20: Line 23:
  
 ^I/O address^Register use| ^I/O address^Register use|
-|BASE+0 (0x0C)|**Read:** Remove one byte of data from the receive FIFO \\  **Write:** Insert one byte of data into the transmit FIFO| +|BASE+0 (0x0C)|**Read:** Remove one byte of data from the receive FIFO \\ **Write:** Insert one byte of data into the transmit FIFO| 
-|BASE+1 (0x0D)|**Read:** Read the Status Register \\  **Write:** Write to the Status Register (note that not all bits are writable)| +|BASE+1 (0x0D)|**Read:** Read the Status Register \\ **Write:** Write to the Status Register (note that not all bits are writable)| 
-|BASE+2 (0x0E)|**Read: **No effect (junk value is returned) \\  **Write****: **Send Immediate – any data queued in the transmit FIFO is sent over the USB at the earliest opportunity. Without this the data will be queued until a timeout (~17ms) expires. Note that the value written to the register is ignored, any value written to the register will trigger the Send Immediate signal.| +|BASE+2 (0x0E)|**Read: **No effect (junk value is returned) \\ **Write****: **Send Immediate – any data queued in the transmit FIFO is sent over the USB at the earliest opportunity. Without this the data will be queued until a timeout (~17ms) expires. Note that the value written to the register is ignored, any value written to the register will trigger the Send Immediate signal.| 
-|BASE+3 (0x0F)|**Read: **No effect (junk value is returned) \\  **Write: **No effect|+|BASE+3 (0x0F)|**Read: **No effect (junk value is returned) \\ **Write: **No effect|
  
 The Status Register bits have the following meanings: The Status Register bits have the following meanings:
Line 37: Line 40:
 |7 (0x80)|**RX_EMPTY:** read-only \\ 0 if the receive FIFO contains queued data, \\ 1 if the receive FIFO is empty. \\ Any reads from the FIFO while it is empty will return junk values.| |7 (0x80)|**RX_EMPTY:** read-only \\ 0 if the receive FIFO contains queued data, \\ 1 if the receive FIFO is empty. \\ Any reads from the FIFO while it is empty will return junk values.|
  
-The **INT_TX** and **INT_RX** bits in the Status Register control the conditions under which an interrupt will be requested. The **IRQ** bit always reflects if either condition is met regardless of the value of **INT_ENABLE**. The bus interrupt line will be asserted only when the **INT_ENABLE** bit is also set. In other words, the bus interrupt line is asserted only when **INT_TX** and/or **INT_RX** are set, one or both of the relevant conditions is met, and **INT_ENABLE** is also set. Sofor example, software which wants to receive an interrupt when data arrives in the receive FIFO over USB should set both **INT_RX** and **INT_ENABLE**. If the interrupt line is shared with multiple devices the interrupt service routine can then check the **IRQ** bit to determine if the USB-FIFO card is requesting the interrupt before calling the USB-FIFO interrupt handler code.+Interrupts: Interrupt requests are controlled in two stages. The first stage is controlled by the **INT_TX** and **INT_RX** bits in the Status Register. Setting these bits to 1 causes an interrupt to be requested when the transmit FIFO has space available (**INT_TX**), or the receive FIFO contains data (**INT_RX**). The **IRQ** bit in the Status Register will be 1 only when either of these bits is set and the corresponding condition arisesThe second stage is the **INT_ENABLE** bit: When the **INT_ENABLE** bit in the Status Register is set, and the **IRQ** bit is 1, the bus interrupt line selected with jumper **J3** will be asserted to interrupt the CPU.
  
-When the USB cable is disconnected, **TX_FULL** =1 and **RX_EMPTY** =1 indicating (correctly!) that data cannot be transferred in either direction.+For example, software which wants to receive an interrupt when data arrives in the receive FIFO over USB should set both **INT_RX** and **INT_ENABLE**. If the interrupt line is shared with multiple devices the interrupt service routine can then check the **IRQ** bit to determine if the USB-FIFO card is requesting the interrupt before calling the USB-FIFO interrupt handler code.
  
-When the ECB machine is resetthe **INT_ENABLE**, **INT_TX**, **INT_RX** and **GPIO_IN** bits are all reset to 0. The USB connection is **not** reset (ie the virtual serial device will remain connected).+When the USB cable is disconnected, **TX_FULL** and **RX_EMPTY** will both be set, indicating that data cannot be transferred in either direction.
  
 +When the ECB machine is reset, the **INT_ENABLE**, **INT_TX**, **INT_RX** and **GPIO_IN** bits are all reset to 0. The USB connection is **not** reset (ie the virtual serial device will remain connected).
 ===== ECB Card Jumpers ===== ===== ECB Card Jumpers =====
  
Line 66: Line 70:
 |J2|2×6 0.1" header|TE Connectivity part 5-826632-0: 2×50 contact breakaway header strip (Farnell order code 3418560)| |J2|2×6 0.1" header|TE Connectivity part 5-826632-0: 2×50 contact breakaway header strip (Farnell order code 3418560)|
 |J3|2×10 0.1" header|TE Connectivity part 5-826632-0: 2×50 contact breakaway header strip (Farnell order code 3418560)| |J3|2×10 0.1" header|TE Connectivity part 5-826632-0: 2×50 contact breakaway header strip (Farnell order code 3418560)|
-|U1, U3, U9|74LS244|TI SN74LS244N (Farnell order code 1739688)|+|U1, U3|74LS244|TI SN74LS244N (Farnell order code 1739688)| 
 +|U9|74AHCT244 (preferred) or 74LS244|TI SN74AHCT244N (Farnell order code 1752769)|
 |U2|74LS245|TI SN74LS245N (Farnell order code 1106085)| |U2|74LS245|TI SN74LS245N (Farnell order code 1106085)|
 |U4|74LS688|TI SN74LS688N (Farnell order code 1470949)| |U4|74LS688|TI SN74LS688N (Farnell order code 1470949)|
 |U5|74LS38|TI SN74LS38N (Farnell order code 1470758)| |U5|74LS38|TI SN74LS38N (Farnell order code 1470758)|
-|U6|74LS139A|TI SN74LS139AN (Farnell order code 9592296)| +|U6|74AHCT139 (preferred) or 74LS139A|TI SN74AHCT139N (Farnell order code 1741539)| 
-|U7, U11|74LS32|TI SN74LS32N (Farnell order code 1740030)|+|U7, U11|74ACT32 (preferred), 74AHCT32 (untested but should work) or 74LS32|TI SN74ACT32N (Farnell order code 1739969), TI SN74AHCT32N (Farnell order code 1749941) or TI SN74LS32N (Farnell order code 1740030)|
 |U8|74LS175|TI SN74LS175N (Farnell order code 1607731)| |U8|74LS175|TI SN74LS175N (Farnell order code 1607731)|
 |U10|Adafruit FT232H Breakout (product 2264)|Mouser order code 485-2264, Digikey order code 1528-1449-ND| |U10|Adafruit FT232H Breakout (product 2264)|Mouser order code 485-2264, Digikey order code 1528-1449-ND|
Line 83: Line 88:
 **Important note on R3, C12: **Footprints are provided for these components but they should not normally be required. **No component** should be fitted at **C12**. A **wire jumper** should be fitted at **R3**. **Important note on R3, C12: **Footprints are provided for these components but they should not normally be required. **No component** should be fitted at **C12**. A **wire jumper** should be fitted at **R3**.
  
-The FT232H /WRITE signal is active on the falling edge of the signal, instead of the standard rising edge. To ensure the data lines are steady for long enough to meet its setup time requirements, the write signal is delayed by routing it through a few gates in U3 and U7. R3 and C12 can form an LC circuit used to extend this delay if required. Alternatively the delay can be shortened by omitting the wire jumper at R3 and connecting U3 pin 17 to U3 pins 5, 7 or 13. Testing indicates that the standard delay should suit all current Retrobrew Computers systems and so the LC circuit components should not be required.+The FT232H /WRITE signal is active on the falling edge of the signal, instead of the standard rising edge. To ensure the data lines are steady for long enough to meet its setup time requirements, the write signal is delayed by routing it through a few gates in U3 and U7. R3 and C12 can form an RC circuit used to extend this delay if required. Alternatively the delay can be shortened by omitting the wire jumper at R3 and connecting U3 pin 17 to U3 pins 5, 7 or 13. Testing indicates that the standard delay should suit all current Retrobrew Computers systems and so the RC circuit components should not be required.
  
 The Adafruit FT232H breakout board can be permanently mounted using either 0.1" breakaway header strips soldered to both boards, or it can be made removable using SIL pin strips and sockets (eg Harwin D01-9922046 and D01-9973246) which allows it to be re-used for other projects. The Adafruit FT232H breakout board can be permanently mounted using either 0.1" breakaway header strips soldered to both boards, or it can be made removable using SIL pin strips and sockets (eg Harwin D01-9922046 and D01-9973246) which allows it to be re-used for other projects.
Line 91: Line 96:
 **For Windows** you need to use the [[http://www.ftdichip.com/Support/Utilities.htm#FT_PROG|FT_PROG]] utility which can be freely downloaded from the FTDI web site. I've made a {{:boards:ecb:usb-fifo:ft232h-template.zip|template}}  that you can load into the FT_PROG program. The program is a bit counter-intuitive so here are some brief instructions: Connect the USB device, run FT_PROG, load the provided XML template. Tell FT_PROG to scan for devices, then right-click on the FT232H USB device (not the template) and tell it to apply the loaded template. This sets the desired configuration for the device. Click the "Program Devices" button in the toolbar, then click the "Program" button. This writes the configuration to the EEPROM. **For Windows** you need to use the [[http://www.ftdichip.com/Support/Utilities.htm#FT_PROG|FT_PROG]] utility which can be freely downloaded from the FTDI web site. I've made a {{:boards:ecb:usb-fifo:ft232h-template.zip|template}}  that you can load into the FT_PROG program. The program is a bit counter-intuitive so here are some brief instructions: Connect the USB device, run FT_PROG, load the provided XML template. Tell FT_PROG to scan for devices, then right-click on the FT232H USB device (not the template) and tell it to apply the loaded template. This sets the desired configuration for the device. Click the "Program Devices" button in the toolbar, then click the "Program" button. This writes the configuration to the EEPROM.
  
-**For Linux** I have written a {{:boards:ecb:usb-fifo:ft232h-program-eeprom.tar.gz|short C program }}  which uses libftdi1 to program the EEPROM. The tarball contains both the source code and a binary with libftdi1 statically linked in. Ensure the FT232H board is the only connected FTDI device (just in case it tries to overwrite the EEPROM in other devices!) and then run "sudo ./program-eeprom -w" to program the device. Running "sudo ./program-eeprom" (without the "-w" option) will report the current EEPROM contents.+**For Linux** I have written a {{:boards:ecb:usb-fifo:ft232h-program-eeprom.tar.gz|short C program }}  which uses libftdi1 to program the EEPROM. The tarball contains both the source code and a binary with libftdi1 and libusb statically linked in, this should work on most recent Linux systems. Ensure the FT232H board is the only connected FTDI device (just in case it tries to overwrite the EEPROM in other devices!) and then run "sudo ./program-eeprom -w" to program the device. Running "sudo ./program-eeprom" (without the "-w" option) will report the current EEPROM contents.
  
-**For MacOS** I had success running FT_PROG in a virtual Windows machine (using Parallels Desktop) using the USB passthrough feature.+**For MacOS** I had success running FT_PROG in a virtual Windows machine (using Parallels Desktop) using the USB passthrough feature. In principle it should also be possible to compile libusb, libftdi1 and use my C program to program the EEPROM but I have not tested this.
  
-It is recommended to use 74LS series parts on this board, at the time of writing it has not been tested with substitutions from other 74 series logic familiesIn particular U1, U2 and U3 benefit from having hysteresis (Schmitt triggers) on the inputs, which the 74LS244 and 74LS245 parts have.+It is possible to build this board with entirely 74LS series logic, and this works well. However slightly higher performance can be achieved by substituting 74AHCT parts for U6 and U9, and 74ACT for U7 and U11. Testing on a Mark IV SBC at 36.864MHz, a board using only 74LS parts requires 2 I/O wait stateswhereas with the 74AHCT parts at U6 and U9 the board operates correctly with only 1 I/O wait state. U7 and U11 can use 74ACT32 which also gives a further timing improvement. The [[https://www.retrobrewcomputers.org/forum/index.php?t=msg&th=142&goto=2061&#msg_2061|forum thread]] has more information on how the timing improves with CMOS partsNote that U1, U2 and U3 should always use 74LS as the bus interface benefits from having hysteresis on the inputs to improve noise rejection; the 74LS244 and 74LS245 parts have Schmitt trigger inputs.
  
 +FT232H boards produced after Feb 2020 (using a USB-C connector instead of Micro-USB) have two additional pins for 3V and GND at the end of the board closest to the USB connector. These should be left disconnected.
  
 ===== Photographs ===== ===== Photographs =====
  
-[[https://www.retrobrewcomputers.org/lib/exe/fetch.php?media=boards:ecb:usb-fifo:ecb-usb-fifo-assembled.jpg|{{:boards:ecb:usb-fifo:ecb-usb-fifo-assembled.jpg?direct&1024x1027}}]]{{:boards:ecb:usb-fifo:ecb-usb-fifo-pcb1.png?nolink&1024x890}}{{:boards:ecb:usb-fifo:ecb-usb-fifo-pcb2.png?nolink&1024x892}}+[[https://www.retrobrewcomputers.org/lib/exe/fetch.php?media=boards:ecb:usb-fifo:ecb-usb-fifo-assembled.jpg|{{:boards:ecb:usb-fifo:ecb-usb-fifo-assembled.jpg?direct&1024x1027|ecb-usb-fifo-assembled.jpg}}]]{{:boards:ecb:usb-fifo:ecb-usb-fifo-pcb1.png?nolink&1024x890}}{{:boards:ecb:usb-fifo:ecb-usb-fifo-pcb2.png?nolink&1024x892}}
  
 ===== Example Code ===== ===== Example Code =====
  
 Note that this code has been optimised on a Z180. On Z80 it may be faster to replace the JR instructions with JP (untested). Note that this code has been optimised on a Z180. On Z80 it may be faster to replace the JR instructions with JP (untested).
- 
 <code> <code>
 +
 FIFO_BASE       = 0x0C FIFO_BASE       = 0x0C
 FIFO_DATA       = (FIFO_BASE+0) FIFO_DATA       = (FIFO_BASE+0)
Line 154: Line 160:
         out (FIFO_SEND_IMM), a  ; we can write any value to the register         out (FIFO_SEND_IMM), a  ; we can write any value to the register
         ret         ret
 +
 </code> </code>
  
-Untested idea: For writes up to 512 bytes in length, believe you could signal Send Immediatethen poll for the RX_EMPTY bit, and then proceed to load up to 512 bytes into the transmit FIFO without checking the RX_EMPTY bit again (using the OTIR instructionor an unrolled loop of OUTIs). I believe the 1KB FIFO in the FT232H is divided into two 512-byte buffers and one is loaded with data while the other is transferred over USB, so once any space in the buffer becomes available you can be confident there is at least 512 bytes of space available. Again, this is untested, but could allow for very fast transmission.+also have file transfer application for CP/MFIFOPIPE. Drop me an email (will /at/ sowerbutts.com) if you'd like to try it out. 
 + 
 +===== Software support ===== 
 + 
 +RomWBW included driver support for the ecb-usb-fifo board. The driver does not support interrupts. It has been confirmed working on the SBC-V2 and the MKIV. Performance is poor compared to normal serial communication but is dependent on processor speed. The driver can be enabled with the following assembly customization: 
 + 
 +<code> 
 +UFENABLE  .SET  TRUE 
 + 
 +</code> 
 + 
 +Inclusion of the driver in RomWBW will result in the board appearing as SIO serial port. The port is virtual in nature and changing serial settings have no affect on it's operation. 
 + 
 +<code> 
 +RetroBrew HBIOS v2.9.2-pre.32019-08-07 
 + 
 +SBC Z80 @ 3.992MHz 
 +0 MEM W/S, 1 I/O W/S, INT MODE 2 
 +512KB ROM, 512KB RAM 
 + 
 +UART0: IO=0x68 16550A MODE=38400,8,N,
 +DSRTC: MODE=STD Thu 2019-08-08 17:42:23 CHARGE=ON 
 +MD: UNITS=2 ROMDISK=384KB RAMDISK=384KB 
 +USB-FIFO: IO=0x0C 
 + 
 +Unit        Device      Type              Capacity/Mode 
 +----------  ----------  ----------------  -------------------- 
 +Disk 0      MD1:        RAM Disk          384KB,LBA 
 +Disk 1      MD0:        ROM Disk          384KB,LBA 
 +Char 0      UART0:      RS-232            38400,8,N,
 +Char 1      SIO0:       RS-232            9600,8,N,
 + 
 +</code> 
 + 
 +Depending on how many character based ports are in your system, you may be able to use CP/M redirection to access the USB-Fifo port. In order for the the USB-fifo board to be used as the console device it must be set as the first RomWBW CIO device through the FORCECON option. 
 + 
 +<code> 
 +FORCECON .SET 2 
 + 
 +</code> 
 + 
 +Serial File transfer using the USB-Fifo can be accomplished using Willl Sowerbutts fifo-pipe program or using XModem. 
 + 
 +====== Windows Driver Configuration ====== 
 + 
 +The Windows FTDI drivers allows the capability of the FT232H device to be configured through the device manager. 
 + 
 +Recommended changes from the default setting are: 
 + 
 +  * Serial Enumerator - unchecked 
 +  * Disable Modem Ctrl At Startup - checked
  
-\\+Detailed driver setting information can be seen in this [[http://www.ftdichip.com/Support/Documents/AppNotes/AN_107_AdvancedDriverOptions_AN_000073.pdf|application note]].
  
  
boards/ecb/usb-fifo/start.1489998522.txt.gz · Last modified: 2017/03/20 04:28 by will
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0