2015-07-16 09:21 AM
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.2015-07-16 09:54 AM
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 5VDon't really need DMA, can be useful for large TX blocks, for RX it's mostly a head-ache.2015-07-16 10:25 AM
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.2015-07-17 03:15 AM
2015-07-17 04:41 AM
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)2015-07-17 07:08 AM
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?
2015-07-17 07:54 AM
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.2015-07-17 07:59 AM
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.2015-07-20 07:13 AM
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.
2015-07-20 08:55 AM
Draw a system diagram