General Category > Discussion - Hardware

SPI Slave



I am using FT4222H-SPI-Slave to send data to an SPI-Master. As you know FT4222H-SPI-Slave appends a dummy byte (0x00) at the first byte automatically.

The master word size is 32-bit, so first I send 3 dummy bytes (0x000000), and then I send the actual data (I want the master to receive first a whole dummy word and then receive the actual data).

So I use FT4222_SPISlave_Write() twice and then notify the master to receive the data, as follows:
1. Call FT4222_SPISlave_Write() to buffer the 3 dummy bytes
2. Call FT4222_SPISlave_Write() again to buffer the actual data (two words: 0xAAAAAAAA, 0xBBBBBBBB)
3. Notify the master to receive the data

1. If the master receives the 3 words from FT4222H-SPI-Slave in one transaction, then it receives { 0x00000000, 0x00000000, 0x00000000 }
2. But if I modified the master code to receive each word in a separate transaction, then it receives { 0x00000000, 0x00AAAAAA, 0xAABBBBBB }

Question-1: Why FT4222H-SPI-Slave doesn't send the data correctly in the one transaction manner?
Question-2: Why FT4222H-SPI-Slave appends a dummy byte in the second word (0x00AAAAAA) in the multiple transactions manner?

Kindly, find attached the analyzer screenshots.

FTDI Community:

If you use FT4222_SPISlave_Write() to write SPI slave data it will append 0x00 in every time the API FT4222_SPISlave_Write() is called.

You can also try to replace FT4222_SPISlave_Write() with FT_Write() as it does not append 0x00 at the beginning.

There are only two USB FIFOs to store the data from PC Host and each FIFO is 512 bytes (but status bytes occupy 2 bytes).
When the API FT_Write() is called, it will send a bulk transfer.
If the transfer size is <512 , it will be treated a short packet transfer and occupy one USB buffer.
If the transfer size is >=512 and <=1024, it will be treated two packets transfer and occupy two USB buffers.
SPI Slave is a passive transfer.
Also make sure the SPI Master sends the clock and do not let the buffer overflow.

Best Regards,
FTDI Community


I have started using FT_Write() to send data to the master.

I have observed that when I call FT_Write() once to send the data, the master receives it correctly. However, in some cases, I have to call FT_Write() multiple times to send the complete data. In such scenarios, the master only receives the first chunk of data correctly since it receives the whole data in one transaction by activating Slave Select once.

I have realized that the master needs to receive each chunk of data in a separate transaction to receive the complete data correctly. By a chunk, I mean the data sent by a call of FT_Write().

Therefore, I would like to inquire if there is a specific configuration that can resolve this issue, or if there is an alternative API that I can use. If neither is possible, could you please suggest another chip that could be used instead of FT4222H?

Thank you for your assistance.

Best regards,

FTDI Community:

If you want to write a big chunk of slave data you can follow the instructions:

1. Set a very big value for write timeouts
For example : = FT_SetTimeouts(ftHandle, 1000, 5000);  // set write timeout of 5 sec

2. Use FT_Write to write the specific size of data. // the size can be very long

Then the writing data will be a continuous data.

When FT_write is executed on SPI Slave transaction. The program will be hold until the sending data finished, or timeout occurs.

Best Regards,
FTDI Community


[0] Message Index

Go to full version