Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FT232H I2C Multi byte reads does not work #1996

Closed
gabbla opened this issue Dec 17, 2022 · 4 comments
Closed

FT232H I2C Multi byte reads does not work #1996

gabbla opened this issue Dec 17, 2022 · 4 comments
Assignees
Labels
bug Something isn't working untriaged

Comments

@gabbla
Copy link
Contributor

gabbla commented Dec 17, 2022

TL;DR Reading more than 1 byte using the FT232H I2C bus result in a bus lock. The single byte reads work as expected.

I am writing a program to control a test bench which is equipped with several IO expanders (PCA9554), a temperature sensor SHT31 and and ADC (ADS7828). The bench is connected to the PC via a FT232H based cable. I am able to interact with the IOEXPs just fine, but when I need to read a temperature or an ADC channel the bus stalls. I investigated further on the ADC side and found that reading more than 1 byte results in a unusable bus.

The reading process is simple: write the channel you want to read, then read 2 bytes.

dotnet_cfg
dotnet_read
dotnet_data

The hardware has been validated with a nucleo, which works as expected:

nucleo

The above Logic2 captures are available: ft232h_dotnet.zip.

Steps to reproduce

Since the ADS7828 is not available in the library, I wrote my driver. I guess you can try to read more than 1 byte from any device and get the same issue.

        public short Read(InputMultiplexer ch)
        {
            Span<byte> writeBuff = stackalloc byte[1]
            {
                ChannelToByte(ch)
            };
            Span<byte> readBuff = stackalloc byte[2];

            i2cDevice.WriteRead(writeBuff, readBuff);
            return BinaryPrimitives.ReadInt16BigEndian(readBuff);
        }

Expected behavior

It should be possible to read more than 1 byte while using the FT232H binding.

Versions used

dotnet --info
.NET SDK:
 Version:   7.0.101
 Commit:    bb24aafa11

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.101\

Host:
  Version:      7.0.1
  Architecture: x64
  Commit:       97203d38ba

.NET SDKs installed:
  7.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
  • System.Device.Gpio 2.3.0-prerelease.22520.10
  • Iot.Device.Bindings 2.3.0-prerelease.22520.10
@gabbla gabbla added the bug Something isn't working label Dec 17, 2022
@ghost ghost added the untriaged label Dec 17, 2022
@Ellerbach
Copy link
Member

Yes, you are write. This is a limitation and should be addressed. It seems there are few more issues with the FT232H.
This should require investigations.

@Ellerbach
Copy link
Member

Note FT4222 has been proved to work nicely: https://github.com/dotnet/iot/tree/main/src/devices/Ft4222

So that can be a good solution for you as well.

@gabbla
Copy link
Contributor Author

gabbla commented Dec 20, 2022

Thank you for the confirmation. I'll take a look during the holidays to see if I can spot anything strange.
Unfortunately I need to stick to the FT232 since my company has stocked several units. Thanks for the suggestion tho!

Gab

@Ellerbach
Copy link
Member

Closing this one as seems to be fixed by the last PR!

@ghost ghost locked as resolved and limited conversation to collaborators Jan 30, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working untriaged
Projects
None yet
Development

No branches or pull requests

2 participants