FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  


Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support

New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Author Topic: LibMPSSE SPI Issue  (Read 651 times)


  • Newbie
  • *
  • Posts: 1
    • View Profile
« on: October 21, 2019, 01:27:05 PM »

Hello! I recently purchased the FTDI C232HM-DDHSL-0 USB cable for use with SPI devices; my goal is to read the memory from an SPI memory chip. However, I am having issues getting the libMPSSE library & 2xx drivers to send signals to a connected memory chip. I hooked the leads of the C232 up to a Saleae logic analyzer and saw that no signals were being output! Following I give a description of my problem. I am new to this, so I will do the best I can to explain :)

I am using a Debian x86_64 machine. The MPSSE SPI download only had the i386 version of the library, so I downloaded the MPSSE SPI source and built the x86_64 bit version. There were no build errors or warnings. I then copied the x86_64 bit libftd2xx.so and .a, libMPSSE.so and .a to /usr/local/lib.

I plugged the cable in, then removed the following kernel modules:

  • ftdi_sio  <-- Readme says to take take out
  • usbserial  <-- Readme says to take out
  • usb_wann  <-- Needed to remove to take out usbserial
  • qcserial  <-- Needed to remove to take out usbserial

I connected 6x cables to the 8 pin memory chip (https://www.macronix.com/Lists/Datasheet/Attachments/7370/MX25L6406E,%203V,%2064Mb,%20v1.9.pdf):

  • VCC <--> red lead
  • Ground <--> black lead
  • Chip select <--> brown lead
  • Data in <--> green
  • serial clock <--> orange
  • Data out <--> yellow

I did not connect hold and write protect pins on the memory chip. Recall my goal is to read the memory out of the chip, and the waveform for the read did not show those pins were necessary.

I am using this simple program:
Code: [Select]
  /* Standard C libraries */
    #include "ftd2xx.h"
    #include "libMPSSE_spi.h"
    FT_HANDLE ftHandle;
    uint8 tx_buffer[4096] = {0};
    uint8 rx_buffer[4096] = {0};
    int main()
        uint8 i = 0;
        int sizeToTransfer = 0;
        int sizeTransfered = 0;
    FT_STATUS status = FT_OK;
    FT_DEVICE_LIST_INFO_NODE devList = {0};
    ChannelConfig channelConf = {0};
    channelConf.ClockRate = 30000000; // 30Mhz
    channelConf.LatencyTimer = 75;
    channelConf.Pin = 0x00000000;/*FinalVal-FinalDir-InitVal-InitDir (for dir 0=in, 1=out)*/
        // Open the channel and dump some information
        status = SPI_GetChannelInfo(0,&devList);
        if (status != FT_OK)
            printf("SPI_GetChannelInfo failed, status = %d\n", status);
            return -1;
        printf("SerialNumber=%s\n",devList.SerialNumber); // TODO: Why blank?
        printf("ftHandle=0x%p\n",devList.ftHandle);/*is 0 unless open*/
        // Open channel 0
        status = SPI_OpenChannel(0,&ftHandle);
        if (status != FT_OK)
            printf("SPI_OpenChannel failed, status = %d\n", status);
            return -1;
        // Initialize the channel: See configuration structure at top of main()
        status = SPI_InitChannel(ftHandle,&channelConf);
        if (status != FT_OK)
            printf("SPI_InitChannel failed, status = %d\n", status);
            return -1;
        // Send the read command (0x03), and read what we get in our receive buffer
    tx_buffer[0] = 0x03;
    status = SPI_ReadWrite(ftHandle, rx_buffer, tx_buffer, sizeToTransfer, &sizeTransfered,
    if (status != FT_OK)
    printf("SPI_ReadWrite failed, status = %d\n", status);
    return -1;
        // Dump the receive buffer to see if we got anything.
    printf("Size transfered = %d\n", sizeTransfered);
    i = 0;
    while (i < sizeTransfered)
        // Cleanup
        status = SPI_CloseChannel(ftHandle);
        if (status != FT_OK)
            printf("SPI_CloseChannel failed, ret = %d\n", status);
    return 0;

To make and run the program:
Code: [Select]
    To compile: gcc read_memory.c -lMPSSE -ldl
    To run: sudo ./a.out

My output is:
Code: [Select]
// The driver can at least detect the cable.
Description=USB <-> Serial
Size transfered = 8
// This output is displayed with I keep the memory chip connected or disconnect it. I believe the following buffer is just junk.

Whether I keep the memory chip connected or disconnected I get the same junk in the receive buffer. I see no LEDs light up on the cable or anything to indicate it is "working." I have tried SPI_Write() and SPI_Read() and get similar behavior. I tested on an Ubuntu VM (running on Windows host) and saw the exact same behavior.

Any help with this matter is greatly appreciated! Thanks