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 13778 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
  • Hero Member
  • *****
  • Posts: 892
    • 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

devangs3

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: FT4222 question from a newbie
« Reply #4 on: December 19, 2019, 09:31:56 PM »

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

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 892
    • View Profile
Re: FT4222 question from a newbie
« Reply #5 on: December 20, 2019, 11:35:43 AM »

Hello,

Is the data being transmitted on the SPI bus, have you managed to scope the lines to check?

Yes the Tx buffer of the FT4222H will persist until the data is read by the master.

Best Regards,
FTDI Community
Logged