I need help with FTDI's FTCSPI Library

Hi,

I'm trying to use the GPI calls in FTDI's FTCSPI library, and I can't seem to make it work. My biggest headache is that I can't find any documentation on the following:

-------------------------- FTC_STATUS Status = FTC_SUCCESS; FTC_HANDLE ftHandle; FTC_CHIP_SELECT_PINS ChipSelectsDisableStates; FTC_INPUT_OUTPUT_PINS HighInputOutputPins;

// Set chip select pin states (ADBUS3 - ADBUS7) ChipSelectsDisableStates.bADBUS3ChipSelectPinState = false; ChipSelectsDisableStates.bADBUS4GPIOL1PinState = false; ChipSelectsDisableStates.bADBUS5GPIOL2PinState = false; ChipSelectsDisableStates.bADBUS6GPIOL3PinState = false; ChipSelectsDisableStates.bADBUS7GPIOL4PinState = false;

// Set GPIO pin states (ACBUS0 - ACBUS3) HighInputOutputPins.bPin1InputOutputState = true; HighInputOutputPins.bPin1LowHighState = false; HighInputOutputPins.bPin2InputOutputState = true; HighInputOutputPins.bPin2LowHighState = false; HighInputOutputPins.bPin3InputOutputState = true; HighInputOutputPins.bPin3LowHighState = false; HighInputOutputPins.bPin4InputOutputState = true; HighInputOutputPins.bPin4LowHighState = false;

Status = SPI_SetGPIOs(ftHandle, &ChipSelectsDisableStates, &HighInputOutputPins);

--------------------------

What I can't find is a definition of what these structure members do. For example, does setting ChipSelectDisableState to false mean that it is not disabled, AKA enabled? And if 'false' for InputOutput state mean input, or output?

If someone could shed some light on this, or point me to some examples, I would appreciate it.

TIA, G.

Reply to
ghelbig
Loading thread data ...

By the looks of things you are rying to use a FT2232 device.

I have a VB6 example up on my site (see sig). The code may help with getting flow sorted.

I don't understand your problem with the above definitions, as they are defined in the Appendix of FTDI SPI Programming Guide, which I believe you must have.

From memory, this sort of documentation is weak on FTDI software along with a few other aspects. They have a habit of putting UNDOCUMENTED examples in their guides assuming you know what everything means, without saying what the result is.

I have not had to use the pin structures to get SPI working to 16 SPI devices.

I would suggest trying a few combinations to see what setting one pin to all combinations does.

-- Paul Carpenter | snipped-for-privacy@pcserviceselectronics.co.uk PC Services Timing Diagram Font GNU H8 - compiler & Renesas H8/H8S/H8 Tiny For those web sites you hate

Reply to
Paul Carpenter

Paul,

Yes, it's a 2232. I should have said so.

I'm not having trouble with the SPI part. In my circuit, I need to wiggle some bits to enable the SPI on the slave device; that is what is not working.

I have no problem with the structure definitions, but the member values are eluding me. Sigh.

Yes, the undocumented example is more confusing than useful. And the function names in the examples (version 1.0) do not exactly match the function call names in the library (version 1.0). Double sigh.

Right now it seems that the set_GPIOs call works only once per device open. The 1st call does something related to the structure elements, but subsequent calls do nothing until the device is closed and re- opened. Unfortunately, closing and re-opening sets the GPIOs to default, which wonks-up the sequence I need to do.

I will take a look at your examples. Thanks!

G.

Reply to
ghelbig

I had the same problem. Maybe you have already given up with the FT2232D but I just posted this to help anyone else who may have this problem again ( it should be on the FTDI web page under their support FAQ's ). I asked Future Technologies for help but I did not even get a reply from the support webpage. I get the impression they are not very good for support or anything else. They make nice chips, but its a pity that they don't even read support questions.

I finally found the reason why the second device would not respond to the SPI call to SPI_Write. The reason was that the first call used a positive edge clock and the second call used a negative edge clock. When you change the edge polarity you better change the dwell clockPinState to be consistent with the clock edge polarity. For Example if you are using a negative edge then set bClockPinState=TRUE if you are using a positve edge bClockPinState=FALSE.

After I changed this the second slave call to SPI_Write worked. I can now program several SPI slaves with different clock edges and chip enable polarities. It took me days to figure this out by trial and error.

Hope this helps

jomegatau

--------------------------------------- Posted through

formatting link

Reply to
jomegatau

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.