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: FT4222 question from a newbie  (Read 2233 times)

josh

  • Newbie
  • *
  • Posts: 3
    • View Profile
FT4222 question from a newbie
« on: February 19, 2018, 03:27:50 PM »

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.
« Last Edit: February 22, 2018, 05:26:31 PM by josh »
Logged

FTDI Community

  • Administrator
  • Sr. Member
  • *****
  • Posts: 337
    • View Profile
Re: FT4222 question from a newbie
« Reply #1 on: February 20, 2018, 03:05:17 PM »

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
Logged

josh

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: FT4222 question from a newbie
« Reply #2 on: February 22, 2018, 03:25:19 AM »

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

Cactus

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: FT4222 question from a newbie
« Reply #3 on: February 22, 2018, 01:52:02 PM »

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)
Logged