FTDI Community

General Category => Discussion - Software => Topic started by: steve on May 11, 2022, 01:58:22 PM

Title: 30MHz SPI CLOCK Frequency in FT2232H mini module
Post by: steve on May 11, 2022, 01:58:22 PM
Hello,

I am using FT2232H mini module with lib-MPSSE file for SPI.
We want 30MHz SPI Clock. we tried to change clockrate function from lib-MPSSE example code so we entered frequency which we want but not able to achieve 30MHz clockrate.

channelConf.ClockRate = 5000;
channelConf.LatencyTimer= 255;
channelConf.configOptions = \
SPI_CONFIG_OPTION_MODE0 | SPI_CONFIG_OPTION_CS_DBUS3;
channelConf.Pin = 0x00000000;/*FinalVal-FinalDir-InitVal-InitDir (for dir 0=in, 1=out)*/

We tried to change above example. so can anyone help me with this code and how to get 30MHz clock rate.
Title: Re: 30MHz SPI CLOCK Frequency in FT2232H mini module
Post by: FTDI Community on May 12, 2022, 03:03:19 PM
Hello,

you can try the following:

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 should set the clock rate to 30MHz.


here is some useful documentation for you:

http://www.ftdichip.com/Support/Documents/AppNotes/AN_135_MPSSE_Basics.pdf (http://url)
http://www.ftdichip.com/Support/Documents/AppNotes/AN_108_Command_Processor_for_MPSSE_and_MCU_Host_Bus_Emulation_Modes.pdf (http://url)

Best Regards,

FTDI Community
Title: Re: 30MHz SPI CLOCK Frequency in FT2232H mini module
Post by: steve on May 16, 2022, 05:37:52 AM
Hello,

Thank you for suggestion.

we tried your configuration in our code, we achieve 30MHz Clockrate but SPI write and SPI read time is not synchronised with clock. we are missing some bits while we read data from slave.

Do you have any idea on that?


Thanks
Title: Re: 30MHz SPI CLOCK Frequency in FT2232H mini module
Post by: FTDI Community on May 16, 2022, 03:02:41 PM
Hello,

have you made sure to initialize the states of the MPSSE pins? command 0x11 makes the clock start low and command 0x10 makes the clock start high.

section 3.3 of https://www.ftdichip.com/Support/Documents/AppNotes/AN_108_Command_Processor_for_MPSSE_and_MCU_Host_Bus_Emulation_Modes.pdf (http://url) explains this further.

Best Regards

FTDI community
Title: Re: 30MHz SPI CLOCK Frequency in FT2232H mini module
Post by: steve on May 18, 2022, 05:22:33 AM
Hello,

I have Checked all MPSSE initialization commands and they are properly initialized.

We are using clockrate of 6 MHz before that time Read and Write working properly. After changing clockrate to 30MHz as per your suggestion, we are facing problem in Write and Read operation.

for eg. with 30MHz Clockrate,
          in Write operation (Address 0x800 & Data = AA)
          During Read Operation (Address 0x800 & Data = 55)

Do you have any suggestion on that?


Thanks
Title: Re: 30MHz SPI CLOCK Frequency in FT2232H mini module
Post by: FTDI Community on May 18, 2022, 10:57:03 AM
Hi,

are you able to send a scope capture of the FT2232H end and at the SPI device end to see if the waveform timing and signal integrity looks ok? 

it may be also worth checking if the SPI device you are using is also in mode0 as the MPSSE engine in the FT2232H isn't compatible with SPI modes 1 and 3


Best Regards,

FTDI Community 
Title: Re: 30MHz SPI CLOCK Frequency in FT2232H mini module
Post by: steve on May 19, 2022, 07:14:53 AM
Hello,

Here i have attached scope images of SPI Write and SPI Read operation with clockrate of 30MHz.

For SPI Write:
Address: 0x3F6, Data: AA

With SPI Read,
Address: 0x3F6, Data: 55

Please check the images and let me know.
Title: Re: 30MHz SPI CLOCK Frequency in FT2232H mini module
Post by: FTDI Community on May 20, 2022, 11:20:05 AM
Hello,

from the wave forms it looks like the data is changing on the rising edge of the clock. you are using SPI mode 0, in this mode the data should be changing on the falling edge of the clock.

it looks like you have the set configuration mode correctly, so this shouldn't be happening. could you run your original code that you first posted and send the wave forms of that please? just so we can compare.

Best Regards
FTDI Community   
Title: Re: 30MHz SPI CLOCK Frequency in FT2232H mini module
Post by: steve on May 23, 2022, 06:57:09 AM
Hello,

Yes I am using SPI mode 0 and i have also captured data with previous code which we are using for data transfer, in that code everything is working fine.

In the image, i have set clockrate of 6MHz(which we are using previously) and
SPI Write: 0x3F6, AA
SPI Read: 0x3F6, AA


Thank you


Title: Re: 30MHz SPI CLOCK Frequency in FT2232H mini module
Post by: FTDI Community on May 24, 2022, 04:24:12 PM
Hi,

the captures don't look as if it is mode0, which is weird because you seem to have set it right in the code. what version of LibMPSSE are you using?


Best Regards,

FTDI Community
Title: Re: 30MHz SPI CLOCK Frequency in FT2232H mini module
Post by: steve on May 25, 2022, 05:23:52 AM
Hi,

We are using LibMPSSE V1.1. And I have selected the SPI MODE0 in code. But the issue is with same mode and 6MHz Clockrate SPI write and read works properly and with 30MHz clockrate its not. Do you have any idea?


Thank you.
Title: Re: 30MHz SPI CLOCK Frequency in FT2232H mini module
Post by: FTDI Community on May 27, 2022, 02:41:34 PM
Hi,

we have a new beta version of LibMPSSE that you can try. if you email in to support1@ftdichip.com i can tell you how to access the beta.

Best Regards

FTDI Community
Title: Re: 30MHz SPI CLOCK Frequency in FT2232H mini module
Post by: Mikexx on February 06, 2023, 12:43:32 PM
Hi,

we have a new beta version of LibMPSSE that you can try. if you email in to support1@ftdichip.com i can tell you how to access the beta.

Best Regards

FTDI Community

What are the improvements to this library? Is it accessible by other users?
Title: Re: 30MHz SPI CLOCK Frequency in FT2232H mini module
Post by: FTDI Community on February 06, 2023, 01:20:12 PM
Hello,

This version of the library has now been released on the website: https://ftdichip.com/software-examples/mpsse-projects/ (https://ftdichip.com/software-examples/mpsse-projects/).

The changes and improvements made in this version are shown in the release notes text file in the library download.

FTDI Community
Title: Re: 30MHz SPI CLOCK Frequency in FT2232H mini module
Post by: Mikexx on February 06, 2023, 02:27:54 PM
Hello,

This version of the library has now been released on the website: https://ftdichip.com/software-examples/mpsse-projects/ (https://ftdichip.com/software-examples/mpsse-projects/).

The changes and improvements made in this version are shown in the release notes text file in the library download.

FTDI Community

Many thanks. I had already come across this version (v1.0.3), and it still has a cmdBuffer[] size of 10 for SPI_ReadWrite().

I can see there were some minor changes from v0.6, ie some commented out lines.

It's also confusing as the "Rivision History" (yes that is how 'revision' is spelled in FTDI_SPI.c) bear no resemblance to the library version. Furthermore the library is dated 2014. Hence my assumption the referenced beta version might be more recent.