cancel
Showing results for 
Search instead for 
Did you mean: 

Setup a USB module (FT232) with a STM32F103 MCU

danesh
Associate II
Posted on July 16, 2015 at 18:21

Hi all,

I have a STM32F103VEH MCU which is connected to a FT232 USB module. All pins at the MCU with alternate functions are connected to the corresponding pins at FT232 USB module, which are:

PA11 -> USBDM (USB data minus)

PA12 -> USBDP (USB data plus)

PC12 -> Tx (alternate function UART5_Tx)

PD2 -> (Rx (alternate function UART5_Rx)

The problem is that I am not sure whether AF_PP or AP_OD should I use for these pins, or whether should I define speed (frequency) for these pins with alternate functions or not? I am almost sure that alternate functions are the correct solution and I don't need to define them as PP/OD output or FLOATING/PU/PD input and define the behavior myself, but would that be also possible instead of alternate function, however, I would prefer to use alternate function? The reason I am asking is that in all samples I have seen (samples which have been published by ST) sometimes Rx have been defined as AF_OD and sometimes it has been defined as floating input, so it is a bit confusing.

My second question is, am I free to chose polling, interrupt, together with or without DMA to improve the performance or for instance, when I am using UART5, I am limited to some options? I know that at UART5 at least does not offer DMA, so I would appreciate if someone can give me more info.

Regards,

Dan.

9 REPLIES 9
Posted on July 16, 2015 at 18:54

You don't cite a specific board/implementation. Watch what TX/RX mean at both ends. Because a real ''TX'' pin (ie the output) needs to go to the USARTx_RX (input) on the STM32 end.

One the F1, the RX pin needs to be in INPUT mode, the TX pin needs to be AF_PP, you almost certainly don't want OD (Open Drain) unless you're doing some weird pull up to 5V

Don't really need DMA, can be useful for large TX blocks, for RX it's mostly a head-ache.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
danesh
Associate II
Posted on July 16, 2015 at 19:25

Yes exactly, Rx and Tx in F1 is connected to Tx and Rx in F232 USB controller, respectively. Should I also define frequency for the alternate function (I think I should)? I also would like to know:

1. What about USBDM and USBPM pins which also have respective alternate functions?

2. If I define Rx at F1 as input , should it be floating input like samples? Also, how can I be informed whether data has been received or not? I have seen examples for polling and interrupt, so would it matter if I use polling or interrupt to know where there is data to be read? Using interrupt is definitely more efficient unless it cannot be used due to limitations.

3. Also I would like to know, if the Rx pin at F1 should be defined as input, so why it has UART5_RX as alternate function and when it is used?

Thanks for your help,

Dan.

danesh
Associate II
Posted on July 17, 2015 at 12:15

Yes exactly, Rx and Tx in F1 is connected to Tx and Rx in F232 USB controller, respectively. Should I also define frequency for the alternate function (I think I should)? I also would like to know:

1. What about USBDM and USBPM pins which also have respective alternate functions?

2. If I define Rx at F1 as input , should it be floating input like samples? Also, how can I be informed whether data has been received or not? I have seen examples for polling and interrupt, so would it matter if I use polling or interrupt to know where there is data to be read? Using interrupt is definitely more efficient unless it cannot be used due to limitations.

3. Also I would like to know, if the Rx pin at F1 should be defined as input, so why it has UART5_RX as alternate function and when it is used?

Thanks for your help,

Dan.

Posted on July 17, 2015 at 13:41

I don't understand the USBDM/DP in this context. Why connect them to the STM32, are you expecting to host this FT232? Don't think that's going to work.

This is how the pins are configured AF_PP (USARTx_TX) and IN_FLOATING (USARTx_RX)

https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/USART%20simulator%20STM32f1xx%20discovery&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=98...

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
danesh
Associate II
Posted on July 17, 2015 at 16:08

Yes I am going to host FT232 USB controller. Well, according to datasheet for STM32F103, pins PA11 and PA12 have USBD and USBDP alternate functions, respectively. So, they are connected to the corresponding USBD and USBDP outputs from FT232 which are finally connected to the USB mini interface (pins 1 and 2 in the USB mini interface). This is the design that I am going to work on. Doesn't it make sense? I guess it should, since alternate function pins i.e. PA11 and PA12 are already there at STM32F103, am I right?

Posted on July 17, 2015 at 16:54

Doesn't it make sense?

Not really, why do you need to use USB to get to a serial USART connection? Just use serial.

Can the F1 USB Host in this fashion, do you have any USB programming experience?

Draw a system diagram of exactly what you're trying to create, because at the moment this seems to be several orders of magnitude more complex than necessary. And I'm not sure you have the skill set to do it.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on July 17, 2015 at 16:59

Perhaps you can answer this:

Why does the USB connect to THREE things, FT232, STM32 and mini-usb connector?

Pick TWO.

If you want to connect to a PC via the FT232 over USB, and the FT232 to the STM32 over serial, then you don't need to wire the USB to the STM32.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
danesh
Associate II
Posted on July 20, 2015 at 16:13

The design is experimental but it is not incorrect. I have a MCU (F1) and FT232. F1 is connected to FT232 (Rx->Tx, Tx->Rx) and FT232 directly to USB connector. The USBDM/USBDP lines from MCU are connected to FT232's USBDM/USBDP as well which I guess might be disconnected, otherwise, the rest is not complicated.

Posted on July 20, 2015 at 17:55

Draw a system diagram

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..