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

Author Topic: Different writing speeds  (Read 519 times)

Flo80

  • Newbie
  • *
  • Posts: 2
    • View Profile
Different writing speeds
« on: February 04, 2019, 11:31:46 AM »

Hi,
I am using FT2232H mini module to write to a N25P256MB memory with an application in C on Windows 10 Professional x64 operation system. I use libMPSEE library v 1.0.0.1, 2014 and FTDI D2XX driver (version 2.12.28) downloaded from https://www.ftdichip.com/Drivers/D2XX.htm.  My problem is that I obtained different speeds for writing data in that memory. For example, for write consecutive pages (256 bytes) with “SPI_Write” function, it  took  16 ms or 60 ms in the same execution of program.

This are the parameters that I used for “SPI_InitChannel” function:
channelConf.ClockRate = 30000000; // 30 MHz;
channelConf.LatencyTimer = 2; //2ms
channelConf.configOptions = SPI_CONFIG_OPTION_MODE0 | SPI_CONFIG_OPTION_CS_DBUS3 | SPI_CONFIG_OPTION_CS_ACTIVELOW;
channelConf.Pin = 0x00000000;

This are the functions that I used to write a page (256 bytes) on memory

   // SET WRITE ENABLE
   sizeToTransfer = 1;
   sizeTransfered = 0;
   buffer[0] = 0x06;   /// WRITE ENABLE   
   status = SPI_Write(ftHandle, buffer, sizeToTransfer, &sizeTransfered,
      SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES |
      SPI_TRANSFER_OPTIONS_CHIPSELECT_ENABLE |
      SPI_TRANSFER_OPTIONS_CHIPSELECT_DISABLE);
       // WRITE DATA
   sizeToTransfer = 261;
   sizeTransfered = 0;
   buffer[0] = 0x02;   /// WRITE COMMAND
   //buffer[0] = 0x12;   /// WRITE COMMAND
   buffer[1] = ((address & 0xff000000) >> 24) & 0x000000ff;
   buffer[2] = ((address & 0x00ff0000) >> 16) & 0x000000ff;
   buffer[3] = ((address & 0x0000ff00) >> 8) & 0x000000ff;
   buffer[4] = (uint8)address;
   status = SPI_Write(ftHandle, buffer, sizeToTransfer, &sizeTransfered,
         SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES |
         SPI_TRANSFER_OPTIONS_CHIPSELECT_ENABLE |
         SPI_TRANSFER_OPTIONS_CHIPSELECT_DISABLE);

Any suggestion on what the problem could be or how to resolve this?
Logged

FTDI Community

  • Administrator
  • Sr. Member
  • *****
  • Posts: 278
    • View Profile
Re: Different writing speeds
« Reply #1 on: February 05, 2019, 04:38:34 PM »

Hello,

Please try with our beta version of LibMPSSE which can be downloaded here:

libMPSSE__0_6_Beta.zip

You may also want to try without the LibMPSSE library and use the D2XX drivers direct. This gives a little more control. Some examples exist here:

https://www.ftdichip.com/Support/SoftwareExamples/MPSSE.htm#SPI

However, this is most likely due to the nature of USB. If there is more USB traffic then the OS and USB have to schedule the communication with each of the USB devices.
It’s highly dependent on the OS and USB Host and is out with our control.
FT2232H use USB Bulk transfers and those are designed to transfer large amounts of data with error-free delivery, but with no guarantee of bandwidth.

Best Regards,
FTDI Community
Logged

Flo80

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Different writing speeds
« Reply #2 on: February 08, 2019, 01:05:48 PM »

Hi,
Thank your for answer.
I tried putting in practice all your suggestion. I think the problem is not because of using LibMPSSE library.I used the D2XX drivers direct, as you suggest, and also use the LibMPSSE_0_6_Beta and the results are the same. I also tried to verify the influence of the OS and USB Host by copying a large amount of data to several USB Sticks in the same time with writing on the memory. I tried to execute the program on others SO (Windows 7, for example). The results were the same: there are only 2 different writing (or reading) speeds s1 and s2 ~= 3,5*s1.
I have observed the SPI bus with Oscilloscope and I saw that the data were transferred with the SPI clock that was set to, but with big gaps between frames (10ms for s1 speed and 30 ms for s2 speed).
I've made some other tests like: put the USB selective suspend setting on Disable, change the clock from 1MHz to 30MHz, put pullup resistors on MISO and CS memory pins, use ResetMemory() function before writing any data and WriteDisable() function after writing data on the memory. 
In conclusion the results were the same. I don’t know what others test to perform. 
If anyone has any suggestions I will be glad to implement it.
« Last Edit: February 10, 2019, 07:57:19 PM by Flo80 »
Logged