[Python] pyftdi: SPI - CLK idle state inverted (mode3)

Discussão em 'Python' iniciado por Stack, Agosto 20, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working with the following setup:

    FT4232H -- SPI-sensor (mode 3)

    Code below should work with Copy&paste and python 3.7. After a powercycle the CLK-Pin of FTDI is high. Once the "spi.get()-line" is passed, it's idle low. It operates normaly during a transaction, but my sensor returns junk, because it assumes the CLK idle high.

    Is this an issue with my FT4232H or a bug in the library (30.3 - pyftdi)? Does someone know wht I've done wrong?

    from pyftdi.spi import SpiController

    spi = SpiController()
    spi.configure('ftdi://ftdi:4232h/1')
    # assumption: after the line CLK should be idle high (which is not)
    slave = spi.get_port(cs=0, freq=1E5, mode=3)
    read_byte=slave.exchange([0x00], 1).tobytes()
    print(read_byte)

    Continue reading...

Compartilhe esta Página