FTDI Community

General Category => Discussion - Hardware => Topic started by: gmetaxas on November 02, 2022, 10:15:26 AM

Title: FT4222H BitWizard breakout and Python
Post by: gmetaxas on November 02, 2022, 10:15:26 AM
I recently purchased a FT4222H breakout board from BitWizard.nl to evaluate the FT4222H IC. My intention is to use that IC in a design and control it using Python.
Configuration for FT4222H: DCNF0=DNCF1=0, VCCIO=3.3 V
Python library that I use to talk to the IC: https://msrelectronics.gitlab.io/python-ft4222/api.html (https://msrelectronics.gitlab.io/python-ft4222/api.html)
I hooked up a 'scope to the four SPI lines and put up a "hello, world" style of Python program that continuously sends a byte over SPI. Please find attached a snapshot from the 'scope's screen, as well as my Python code.
It turns out that the signal on the SS0O pin has the wrong polarity: it should be low when SCK is active and high elsewhere.
What should I do to get this right? Should I pull up that pin, or is there any software setting that has been overlooked? Please advise.
Title: Re: FT4222H BitWizard breakout and Python
Post by: gmetaxas on November 04, 2022, 09:38:45 AM
Well, I checked the hardware and found nothing wrong with it. However, after carefully examining the Python code I noticed the following:
In the code I posted here, the call to the SPI initialization method is:
Code: [Select]
    dev.spiMaster_Init(ft4222.SPIMaster.Mode.SINGLE,
                       ft4222.SPIMaster.Clock.DIV_512,
                       ft4222.SPI.Cpol.IDLE_HIGH,
                       ft4222.SPI.Cpha.CLK_LEADING,
                       ft4222.SPIMaster.SlaveSelect.SS0)
and in the example that is listed in the library webpage (https://pypi.org/project/ft4222), the SPI is initialized like this:
Code: [Select]
import ft4222
from ft4222.SPIMaster import Mode, Clock, SlaveSelect
from ft4222.SPI import Cpha, Cpol
...
# open 'device' with default description 'FT4222 A'
devA = ft4222.openByDescription('FT4222 A')
...
# init spi master
devA.spiMaster_Init(Mode.SINGLE,
                    Clock.DIV_128,
                    Cpol.IDLE_LOW,
                    Cpha.CLK_LEADING,
                    SlaveSelect.SS0)
Using the code in the PyPI.ft4222 library webpage (https://pypi.org/project/ft4222), the signals on the SPI lines are correct. Refer to the attached screenshot from the 'scope.
Clock frequency is 465.65 kHz and clock divider is set to 128, therefore the system clock for the FT4222 IC runs at 60 MHz.
Therefore, I consider the problem to be solved and I would ask the moderator to move that post to the software section, as there is nothing special about hardware in this.