The supported Altera devices are an excellent choice to implement SD/SDIO device multiplexers. The supported devices’ low power, high I/O pin count, and ability to tolerate any possible power-on sequence on their core and I/O banks make them an ideal choice in this application.
It may often be required for an SD host controller with a single SD interface to support more than one SD device. The SD protocol and standards recommend doing this using one of following two methods:
- Use a bidirectional multiplexer between the SD host and the multiple SD devices and use this multiplexer to multiplex the data lines. This is performed while the clock line is connected to each of the multiple SD devices.
- Retain the data lines connected to the multiple SD devices while multiplexing the unidirectional clock line.
This design example uses the second method described above.
The detailed description of the implementation is based on the MAX II devices. This application can also be implemented in MAX V and MAX 10 devices.
The “MUX” in Figure 1 represents a unidirectional multiplexer that is implemented using a MAX II device. The select line for the multiplexer is controlled through an I2C interface, which is also implemented in the same device. The multiplexer is thus an I2C slave, and the clock line from the host controller is either connected to the SD Device A or the SD Device B, depending on the I2C data received.
The I2C interface implementation in the MAX II device (I2C slave) has a 7-bit address and follows the general I2C protocol. The start signal is sent by the master, followed by the 7-bit address and an R/W bit. When the address broadcast on the I2C bus matches with the slave device’s address, an ACK (acknowledge) signal is sent by the device. This is followed by a DATA byte, as per the select line selection that is required by the master. This is then followed by another ACK signal by the slave. The end of a session of data transaction is when the Stop (P) signal is sent by the master.
|SDA||I2C Serial Data||Bidirectional|
This design example can be implemented with the EPM240G or EPM240 device or any other MAX II device. It is demonstrated in an I2C bus environment. Implementation involves using this design example source code and allocating I2C bus lines, the SD host controller clock line, the eject line, and the clock lines for the SD Device A and SD Device B. An LED indicator that is used to indicate the current selection is connected to an output port assigned to display the select line status. This SD multiplexer is demonstrated on the MDN-B2 demo board and with the help of an I2C simulator. The simulator is created using a PC parallel port and interfacing hardware to create an I2C-compliant two-wire bus. The MDN-B2 features two SD sockets to accommodate two SD devices (to be multiplexed) and an SD card-shaped PCB adapter that fits into a standard SD socket of an SD host.
The utility program, which uses the parallel port, and its hardware interface with the MAX II-based multiplexer and provide the SDA and SCL connections as required on an I2C two-wire system. When implemented, this design allows the I2C master (or the control panel of the Maxim utility) to control the select line of the MAX II-based multiplexer on the MDN-B2. The following table lists the EPM240G pin assignments for this design example.
|APD_inhibit||Pin 14||APD_inhibit_inv||Pin 12|
|eject||Pin 64||SCLK||Pin 39|
|SDA||Pin 40||sdA_clock||Pin 2|
|sdB_clock||Pin 7||sd_host_clock||Pin 28|
To demonstrate this design on the MDN-B2 demo board, perform the following steps:
- Turn on the power to the demo board (using slide switch SW1).
- Download the design onto the MAX II device through the JTAG header JP5 on the demo board and a conventional programming cable (ByteBlaster™ II or USB-Blaster™).
- Keep SW4 on the demo board pressed before and during the start of the programming process.
- Once completed, turn off the power and remove the JTAG connector.
To set up a parallel port driven I2C environment on your PC, perform the following steps:
- Download a software utility, such as the Maxim parallel port utility, to communicate with the slave in the I2C defined protocol. Install the parallel port software. (The ParDS2W.exe program is used in this example.)
- You must install a parallel port driver to enable access to the parallel port in Windows XP or Windows 2000 for this parallel port utility.
- After installation, you must configure the Direct-IO program. Open the Windows control panel and click the Direct IO icon.
- Enter the Begin and End addresses of your parallel port (normally, this is 378 through 37F; however, confirm your PC’s parallel port address by looking at the settings in Control Panel/System/Hardware/Device Manager/Ports/ECP Printer Port (LPT)/Resources.
- Configure the parallel port to ECP by changing the BIOS settings when you start your PC.
- Next, select the Security tab of the Direct IO control panel and browse to the directory path of the ParDS2W.exe program.
- Click Open and then click Add to add the program. The path of this utility is shown in the Allowed Processes field. Click OK.
- Attach the parallel port I2C dongle that is supplied along with the MDN-B2 demo board. Use an extension cord, if necessary, to extend the parallel port connection closer to your demo board.
- Attach the 4-pin socket on the pigtail of the I2C parallel port dongle to the I2C header (JP3) of the demo board so that the red mark on the socket meets pin 1 on the JP3 header.
- Open the ParDS2W program, select the appropriate parallel port address of your PC (as seen when configuring Direct IO) and set the 2-Wire Device Address to 00h.
- Finally, you can test the I2C setup on the Test Circuit tab to see if you have a Test PASS message in the Status window. If you do, the I2C environment is set.
To set up the SD host/card reader to work with the MDN-B2 demo setup, perform the following steps:
- Use a general purpose USB SD card reader modified to access the card detect line from its SD socket.
- Ensure that the USB cable to the SD card reader is disconnected and the power switch on the MDN-B2 is turned off.
- Fix the SD card-shaped PCB adapter in the SD card reader’s SD socket, and then insert two SD memory card devices in the two SD sockets on the MDN-B2.
- Connect the card detect line tapped from the SD card reader to the MDN-B2 board through pin 5 on JP8.
Turn on the MDN-B2 and then connect the USB cable to the SD card
“My Computer” on the PC to which the card reader is connected shows one of the SD memory cards.
Using the parallel port utility, perform a write operation into the I2C
Observe the corresponding changes in the “My Computer” listing of the appropriate SD memory card that was multiplexed.
- To do a write I2C operation, press Start followed by Write Byte. Enter hex byte 00 in the field adjacent to Write Data and click Write Data.
- This will select one of the SD devices. Similarly, writing FF will select the other SD device. LED D12 on the MDN-B2 will change its state accordingly.
|December 2007||1.0||Initial release.|