FTDI Community

General Category => Discussion - Software => Topic started by: 9ghtX on December 03, 2020, 05:22:23 AM

Title: Zeros in output from FT220X (C#)
Post by: 9ghtX on December 03, 2020, 05:22:23 AM
 I tried to get data from my FT220X using ftDevice.Read() and ftDevice.Purge(ref readData), but there is only zeros in data. I checked hardware signals and there is everything OK.
 So, the question. May be there problem in code (I've attached it to this topic) that causes this problem?

Hardware specifics:
 Clock: 40 Mhz
 Receiving package has 4 bytes
 Connected 2 devices FT234XD via 485 (using Serial.IO C# lib) and FT220X via SPI (using FTD2XX.dll).
Title: Re: Zeros in output from FT220X (C#)
Post by: FTDI Community on December 04, 2020, 04:32:39 PM
Hello,

Please refer to the FT220X Product Page:

https://www.ftdichip.com/Products/ICs/FT220X.html (https://www.ftdichip.com/Products/ICs/FT220X.html)

Please note that this is not an SPI master.

FT220X implements FT1248 which is a proprietary FTDI interface that allows for a synchronous parallel/ serial interface where the data bus may be 1, 2, 4 or 8 bit wide.
This is not a standard SPI slave.

Data transfer rates up to 1MByte/s.

These app notes should help you:

AN_206 FT1248-1 Bit SPI (https://www.ftdichip.com/Support/Documents/AppNotes/AN_206_FT1248-1 Bit SPI.pdf)
AN_167 FT1248 Dynamic Parallel/Serial Interface Basics (https://www.ftdichip.com/Documents/AppNotes/AN_167_FT1248_Parallel_Serial_Interface_Basics.pdf)
AN_173 Establishing FT1248 Communications using a Morph-IC-II (https://www.ftdichip.com/Support/Documents/AppNotes/AN_173_Establishing_FT1248_Communications_using_a_Morph-IC-II.pdf)

Have you considered our latest SPI slave product the FT4222H?
Do you require an SPI master or slave?

Best Regards,
FTDI Community
Title: Re: Zeros in output from FT220X (C#)
Post by: 9ghtX on December 07, 2020, 05:18:08 AM
Recently I tried to write program on C++, guided by your instructions on official cite. So, after completing writing I got on RxBytesBuffer strange data package. I get, for example, 0x00AFF738 and this bytes always change in ever iteration of using program.

Also I notice that this values have difference in 12. If I printf() them in %lu, I get RxBytes: 0x6421720, TxBytes: 0x6421732 and RxBuffer: 0x6421444. Is this kinda encrypting? And if this packages always change and they are encrypted, how I can uncrypt them?

In my device this chip in Slave mode. I need get 5 bytes, that contains answers from my SPI-Master device. And after getting command I need to write an answer to Master and continue communicate with it at same time with 485 port (but with communicating with 2 devices I have no problem).
Title: Re: Zeros in output from FT220X (C#)
Post by: FTDI Community on December 07, 2020, 02:03:39 PM
Hello

Thank you for your update.
There is no encryption used on the FT220X, what API call are you using when the following happens:
 
Also I notice that this values have difference in 12. If I printf() them in %lu, I get RxBytes: 0x6421720, TxBytes: 0x6421732 and RxBuffer: 0x6421444. Is this kinda encrypting? And if this packages always change and they are encrypted, how I can uncrypt them?

Can I see this code snippet?

Best Regards,
FTDI Community
Title: Re: Zeros in output from FT220X (C#)
Post by: 9ghtX on December 08, 2020, 03:39:53 AM
I found a problem about this random numbers.

After solving all problems with reading, now I get zeros as via C# lib. I write all readed data in byte array and write in console every byte from it. And all bytes in array are zeros. As you can see at screenshot, there is bytes in RxBytes (that displays allowed to read bytes in buffer). There is 4 of them, readed data bytes have only 0 value.
Title: Re: Zeros in output from FT220X (C#)
Post by: FTDI Community on December 08, 2020, 05:16:20 PM
Hello,

Thanks for your code, I cannot see any glaring issues with it immediately.

However I did notice you are trying to print the 'RxBuffer' data as a unsigned long:
Code: [Select]
printf("Data Recieved: 0x%lu\n", RxBuffer[i]);
But RxBuffer is defined as a char array.

Could you also double check the data being received by the FT220? I.e what is the expected 4 bytes?

Best Regards,
FTDI Community
Title: Re: Zeros in output from FT220X (C#)
Post by: 9ghtX on December 09, 2020, 05:14:47 AM
 I tried to define RxBuffer differently: integer, char, DWORD just for experiment. That doesn't change nothing

 As I checked, there must be at least one 4 (or 5, that's another question, why I get 4 bytes instead 5, when timings are Ok) bytes package {0x9E, 0x00, 0x00, 0x00, 0x03}.

 Another question. There is MIOSIs in FT1248 controller. The 0s' one is only for OUTPUT or for both of them?

Title: Re: Zeros in output from FT220X (C#)
Post by: FTDI Community on December 09, 2020, 05:40:33 PM
Hello,

It was more in relation to the prinft statement using the unsigned long identifier, and not how the rxBuffer is defined.

Can you take a logic capture of the device receiving this data?

MIOSIO[0] is the bi-directional data line, which the master must read or write to.

Best Regards,
FTDI Community
Title: Re: Zeros in output from FT220X (C#)
Post by: 9ghtX on December 10, 2020, 04:11:46 AM
 I found out that I needed to write in FT220X 0x00 bit first to initialize Master Write Slave Read mode.
"Write 0x00 Write request command" - From FT220X Datasheet

 Do I need to write to FT220X in my program first bit 0x01 to init Master Read Slave Write mode? Or it does this bt itself and I don't need to write anything?
"Read 0x01 Read request command" - From FT220X Datasheet

 Or for easily for me to understand you could write little example, how to Write via FT220X correctly.

 Here is my thoughts:
If I want to read message from Master, I need to send to my FT220X 0x00 in first bit of my byte data.
If I want to write data from my FT220X to Master, what should I do? Write first bit 0x01? Or it happens automatically? Does it add first bit 0x01-write-command and will my Master see this bit?
So many questions..)
Title: Re: Zeros in output from FT220X (C#)
Post by: anoopkyadav on March 02, 2022, 02:30:25 PM
Sir / Madam ,

Has anybody found the solution for ZERO's Received .

I am using UMFT221XE-01 module for Receiving SPI Data from my custom board(Master).
I have made a GUI in C# to receive the SPI data from my Custom Board(Master).

When I am reading the SPI data in the Rx Buffer It's Showing 0000 (All Zeros) , Even Though the available bytes to read are showing Non Zeros .

Pls suggest how to read data in SPI Slave mode.

Pls share a sample code if available