General Category > Discussion - Software

FT4222 question from a newbie

(1/2) > >>

josh:
Hi all,
I am trying to write my very first FTDI driver for the FT4222H chip in SPI slave mode.
I'm trying to write code to send DLen bytes of data to the master using a short slave transfer (without checksum) command according to the protocol in page 22 of this doc http://www.ftdichip.com/Support/Documents/AppNotes/AN_329_User_Guide_for_LibFT4222.pdf.

However, it is not working. Assuming I always check that ftStatus equals OK, here is the code. Am I doing something wrong?

ftStatus = FT_CreateDeviceInfoList(&dwNumDevs);

ftStatus |= FT_GetDeviceInfoList(devInfo, &dwNumDevs);

ftStatus |= FT_OpenEx((PVOID)(uintptr_t)devInfo.LocId,FT_OPEN_BY_LOCATION, &ftHandle);

ftStatus |= FT4222_SPISlave_Init(ftHandle);

ftStatus |= FT4222_SPI_SetDrivingStrength(ftHandle, DS_8MA, DS_8MA, DS_8MA);

char sp[5] = {0x5a, 0x83, serial_num, (DLen & 0xff) >> 8, DLen & 0xff };

ftStatus |= FT4222_SPISlave_Write( ftHandle, sp, 5,&sizeTransferred);
ftStatus |= FT4222_SPISlave_Write( ftHandle, Buffer, DLen, &sizeTransferred);


Thanks.

FTDI Community:
Hi,

Can you take a look at the Examples contained in v1.4.0 of the LibFT4222 Windows Library, available here:

http://www.ftdichip.com/Support/SoftwareExamples/LibFT4222-v1.4.zip

If you are still having problems please contact us on support1@ftdichip.com and we will assist you further.

Best Regards,
FTDI Community

josh:
What is the size of the internal SPI shift register in slave mode?

Cactus:
Hi Josh,
My (also newbie experience) with the FT4222h has been that to send data to a master from the FT4222 you only need to use FT4222_SPISlave_Write(handle,Buffer,dlen, &sizeTransferred).
However with the microprocessor you need to send clock signals, and then the buffer is transferred from the FT4222 when it is clocked by the master.
If you wish to send data from the master to the FT4222h however you need to use the 0x5a, 0x83... etc code (see photo).
Attached is a screenshot of the SPI trace (MOSI and CLK) of a microprocessor (Master) communicating with the FT4222h(as slave)

devangs3:
Hi,
I have a similar trouble with using the SPISlave_Write function from the win32 app to an ARM master. When I execute this function, my ARM master core cannot catch the data sent by the PC. Does this mean the ARM core has to continuously poll the FT4222? Does the TX buffer of FT4222 not persist until it is read? Any ideas appreciated. 

Navigation

[0] Message Index

[#] Next page

Go to full version