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: Issue with FT4222 and I2C  (Read 1402 times)

petewall

  • Newbie
  • *
  • Posts: 2
    • View Profile
Issue with FT4222 and I2C
« on: April 25, 2018, 03:25:59 PM »

I am having some trouble communicating with a chip over I2C and I'm wondering if I'm doing something wrong when setting up the FT4222 chip.

Some overview of my circuit, I have the FT4222 chip connected to my computer over USB, and I want to use it to communicate to other chips on circuit over I2C.  The first chip to communicate with is a PCA9570, a four pin GPIO chip, that controls two LEDs and two reset pins for other chips on the board.  Initially, the PCA9570 is high on all four outputs, so my first job is to tell the PCA9570 to set those outputs low.

I'm building the software on Mac OS X 10.13.4, with g++:
Code: [Select]
$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.1)

Here's an overview of the software:
I find any available chips...
Code: [Select]
FT_CreateDeviceInfoList(&numOfDevices)... connect to the first one...
Code: [Select]
FT_OpenEx(locationId, FT_OPEN_BY_LOCATION, &ftHandle);... Initialize I2C...
Code: [Select]
FT4222_I2CMaster_Init(ftHandle, 400);... and reset I2C.
Code: [Select]
FT4222_I2CMaster_Reset(ftHandle);
All of these succeed with FT_OK return codes.  A call to FT4222_I2CMaster_GetStatus returns 0x20 (controller idle).

The PCA9570's data sheet (https://www.nxp.com/docs/en/data-sheet/PCA9570.pdf) specifies running these commands.  First, I send the general I2C reset (sending 0x06 to 0x00):
Code: [Select]
uint8 buffer = 0x06;
uint16 sizeTransferred;
FT4222_STATUS status = FT4222_I2CMaster_Write(ftHandle, 0x00, &buffer, 1, &sizeTransferred);
This succeeds and another call to FT4222_I2CMaster_GetStatus still returns 0x20 (controller idle).

Now, I send the command to pull all pins low on the GPIO chip:
Code: [Select]
uint8 pins = 0x00;
uint16 sizeTransferred;
FT4222_STATUS status = FT4222_I2CMaster_Write(ftHandle, GPIO_CHIP_ADDR, &pins, 1, &sizeTransferred);

The status for this is still FT_OK, but the LEDs are still on.  Also, the next call to FT4222_I2CMaster_GetStatus returns 0x3e.

So, how can I best debug why my I2C commands are not going through?
Logged

FTDI Community

  • Administrator
  • Full Member
  • *****
  • Posts: 229
    • View Profile
Re: Issue with FT4222 and I2C
« Reply #1 on: April 25, 2018, 04:19:22 PM »

Hello,

Unfortunately we don't have any particular experience using the PCA9570.

However, we do provide code examples as part of the LibFT4222, so it would be worth taking a look at these:

http://www.ftdichip.com/Products/ICs/FT4222H.html

There is also a lot of information in LibFT4222 User Guide including details of the FT4222_STATUS return codes (Appendix A – Enumeration and Structure Definitions) and FT4222_I2CMaster_GetStatus controllerStatus bit definitions which should help with your debug.

Best Regards,
FTDI Community
Logged