FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

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

Show Posts

You can view here all posts made by this member. Note that you can only see posts made in areas to which you currently have access.

Messages - FTDI_user

Pages: [1]
1
I contacted the FTDI support directly and managed to solve my problem. To help others, which may have the same problem, I want to share my solution here.

Removing the LibMPSSE and using D2XX library will increase the speed of writing and reading a lot. My solution is based on this example:

https://www.ftdichip.com/Support/Documents/AppNotes/AN_114_FTDI_Hi_Speed_USB_To_SPI_Example.pdf

U4 SPI_FTDI_WRITE(FT_HANDLE handle, SPI_READBUFFER_pt pReadBuf, uint8* buffer, const U4 sizeToTransfer)
{
    uint32 sizeTransfered = 0;
   
   //SPI_Enable();
   for (int loop = 0; loop < 5; loop++) //one 0x80 command can keep 0.2us, do 5 times to stay in this situation for 1us
   {
        OutputBuffer[dwNumBytesToSend++] = '\x80';                     // GPIO command for ADBUS
      OutputBuffer[dwNumBytesToSend++] = '\xf0';                     // set CS low, MOSI and SCL
      OutputBuffer[dwNumBytesToSend++] = '\xfb';                     // bit3: CS, bit2: MISO, bit1: MOSI, bit0: SCK
   }
   
   //send data
   OutputBuffer[dwNumBytesToSend++] = MSB_FALLING_EDGE_CLOCK_BYTE_OUT_IN;      // 0x11 Write command
   OutputBuffer[dwNumBytesToSend++] = (sizeToTransfer - 1);               // Length lower byte
   OutputBuffer[dwNumBytesToSend++] = (sizeToTransfer - 1) >> 8;                 // Length higher byte
   

   for (U4 i = 0; i < sizeToTransfer; i++)  // size to transfer
   {
      OutputBuffer[dwNumBytesToSend++] = buffer;
   }

   //SPI_CSDisable();
   for (int loop = 0; loop < 5; loop++) //one 0x80 command can keep 0.2us, do 5 times to stay in this situation for 1us
   {
      OutputBuffer[dwNumBytesToSend++] = '\x80';      //GPIO command for ADBUS
      OutputBuffer[dwNumBytesToSend++] = '\xf8';      //set CS, MOSI and SCL low
      OutputBuffer[dwNumBytesToSend++] = '\xfb';      //bit3:CS, bit2:MISO, bit1:MOSI, bit0 : SCK
   }

   ftStatus = FT_Write(handle, OutputBuffer, dwNumBytesToSend, &sizeTransfered);

   dwNumBytesToSend = 0;                        

   ftStatus = FT_Read(handle, inBuffer, sizeToTransfer, &dwNumBytesRead);
   sizeTransfered = sizeTransfered ? sizeTransfered - 33 : sizeTransfered;
}

uint32 SPI_FTDI_READ(FT_HANDLE handle, SPI_READBUFFER_pt pReadBuf, uint8* spiData, uint32 size)
{
   const uint32 secureSize = MIN(50, size); 

   uint32 sizeRead;

   dwNumBytesSent = 0;

   //SPI_Enable();
   for (int loop = 0; loop < 5; loop++) //one 0x80 command can keep 0.2us, do 5 times to stay in this situation for 1us
   {
      OutputBuffer[dwNumBytesToSend++] = '\x80';// GPIO command for ADBUS
      OutputBuffer[dwNumBytesToSend++] = '\xf2';// set CS, MOSI and SCL low
      OutputBuffer[dwNumBytesToSend++] = '\xfb';// bit3:CS, bit2:MISO, bit1:MOSI, bit0 : SCK
   }

   //read data
   OutputBuffer[dwNumBytesToSend++] = MSB_FALLING_EDGE_CLOCK_BYTE_IN;
   OutputBuffer[dwNumBytesToSend++] = (secureSize - 1);      
   OutputBuffer[dwNumBytesToSend++] = (secureSize - 1) >> 8;      

   //SPI_CSDisable();
   for (int loop = 0; loop < 5; loop++) //one 0x80 command can keep 0.2us, do 5 times to stay in this situation for 1us
   {
      OutputBuffer[dwNumBytesToSend++] = '\x80';//GPIO command for ADBUS
      OutputBuffer[dwNumBytesToSend++] = '\xfa';//set CS, MOSI and SCL low
      OutputBuffer[dwNumBytesToSend++] = '\xfb';//bit3:CS, bit2:MISO, bit1:MOSI, bit0 : SCK
   }
   
   ftStatus = FT_Write(handle, OutputBuffer, dwNumBytesToSend, &dwNumBytesSent);
   dwNumBytesToSend = 0;
   ftStatus = FT_Read(handle, spiDataRest, secureSize, &sizeRead);

}


2
Hi Dania,

I face the same problem. Did you find out, how to solve it?

When I measure the transmition, I see different behavior using MPSSE_SPI vs D2XX library.

Setup:
-SPI
-3MHz CLK

D2XX:
Duration transmit data = 22us
Duration disasserting SS = 171us

MPSSE:
Duration transimt data = 22 us
Duration disasserting SS = 2.9ms

The problem seems to be related to the MPSSE library. Otherwise the duration time to release the SS should be the same for D2XX and MPSSE.

Can somebody from FTDI support re-check the MPSSE library? Especially the releasing SS part of the code...

Pages: [1]