cancel
Showing results for 
Search instead for 
Did you mean: 

How to drive a FT232 chip by STM32 USB HOST CDC example?

Junde
Senior III

Hi there,

I am working on a project that requires sending just two commands to an FT232 chip and waiting for the response data.

I can already successfully communicate the STM32 USB HOST CDC and the STM32 USB DEVICE CDC (refer to repo's first commit ).

However, while I was trying to modify the USB HOST CDC example to work with FT232(refer to the above repo's second commit), it didn't work.

Can anyone give me some advice or demo code?

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Junde
Senior III

Hi there, 

After some tries, I can use the STM32F429 to communicate with the FT232. (Refer to the source code in the attachment)

However, there are some bugs in the code:

1. There are always 2 more bytes to be received at the beginning of the data frame. (I ignore the first 2 bytes now)

2. Some frames can be received more than once. (I compare the continuously received frames and ignore the same ones.)

3. After re-plugging the FT232 device, the device can't work. (How to support the hot plug)

(And I already tried the STM32F1 Device CDC example with the same HOST code; all the above problems do not exist.)

Below are the LOG for the STM32F1 Device(left) and the FT232 Device(right):

Junde_1-1760674334317.png  Junde_2-1760674355342.png

I don't know the reason why the FT232 can't support the hot plug function.

View solution in original post

9 REPLIES 9
TDK
Super User

If you want UART, why not cut the FT232 chip out and use UART directly from the STM32?

If you feel a post has answered your question, please click "Accept as Solution".

Hi @TDK ,

Thanks for your reply.

The FT232 is integraded in a module that we must use, and that module is not manufacture by ourself.

So that's why we need to build communication with it.

Andrew Neil
Super User

See this recent thread: STM32F407 USB Host config for FT232RL.

As noted there by @waclawek.jan, the FT232 is not a standard CDC class device - so you'll have to look at its descriptors and you would need a custom driver for it. 

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

@Junde wrote:

The FT232 is integraded in a module that we must use,


"must"?

What compels you?

 


@Junde wrote:

that module is not manufacture by ourself.


So have you tried contacting the manufacturer for support?

Or maybe contact FTDI for support in hosting their chips on a microcontroller?

 

PS:

Perhaps this might help: https://github.com/hathach/tinyusb/discussions/725#discussioncomment-505374 ?

via Google search for "ft232 host stm32"; other internet search engines are available.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Junde
Senior III

Hi there, 

After some tries, I can use the STM32F429 to communicate with the FT232. (Refer to the source code in the attachment)

However, there are some bugs in the code:

1. There are always 2 more bytes to be received at the beginning of the data frame. (I ignore the first 2 bytes now)

2. Some frames can be received more than once. (I compare the continuously received frames and ignore the same ones.)

3. After re-plugging the FT232 device, the device can't work. (How to support the hot plug)

(And I already tried the STM32F1 Device CDC example with the same HOST code; all the above problems do not exist.)

Below are the LOG for the STM32F1 Device(left) and the FT232 Device(right):

Junde_1-1760674334317.png  Junde_2-1760674355342.png

I don't know the reason why the FT232 can't support the hot plug function.


@Junde wrote:

I already tried the STM32F1 Device CDC example with the same HOST code; all the above problems do not exist


As already noted, the FT232 is not a standard CDC device - so that's to be expected.

 


@Junde wrote:

I don't know the reason why the FT232 can't support the hot plug function.


It's not the FT232 - that certainly copes with hot-plugging on other systems - so it must be something missing/wrong in your code...

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Hi @Andrew Neil 

Thanks for your reply.

It's not the FT232 - that certainly copes with hot-plugging on other systems - so it must be something missing/wrong in your code...

Yes, I know there must be something wrong with the code, but I don't know where and why it is.

Have you tried contacting FTDI, searching online, etc?

 

Try adding further instrumentation in your code to see where & why, exactly, it's failing.

Do you have a USB analyser?

 

Do you really need to use an STM32? eg, a Raspberry Pi works fine with FTDI chips...

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

@Andrew Neil 

Thanks for your patient instruction.

After re-discussion with the team, we decided to change the solution. (communication with this FT232 module by PC directly)

Have a good day!