cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4Discovery Virtual COM port

jurij
Associate II
Posted on July 10, 2012 at 22:00

Hello!

I would like to send simple data from STM32F4Discovery to PC (''Hello World!'' every second would be perfect for beginning).

I am pretty lost here. How do I create virtual COM port? When I connect PC to the board via Mini USB, everything is normal - board gets detected and I can use it and upload programs normally. But when I connect also micro USB port, nothing happens on computer (only LD7 green light goes ON on board). Is there any simple tutorial on how to do this? Thanks!
18 REPLIES 18
Posted on July 10, 2012 at 22:39

Review the examples in the USB libraries

http://www.st.com/internet/com/SOFTWARE_RESOURCES/SW_COMPONENT/FIRMWARE/stm32_f105-07_f2_f4_usb-host-device_lib.zip

You might have to do some work to port examples to the STM32F4-Discovery, I believe most of the examples assume you have the higher end STM32xxx-EVAL series boards. Going to be a bit of a bear for the beginner.

I've done some porting for the mass-storage controller example. Getting the virtual serial working is something on the strategic wish list.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jurij
Associate II
Posted on July 10, 2012 at 23:00

I see, thanks. I think it will be much more simple to actually buy USB-RS232 converter and connect it to the STM32F4 board, what do you think? Something like this: http://www.ebay.co.uk/itm/NEW-USB-TO-RS232-SERIAL-DB9-1PORT-CABLE-WORK-WINDOWS-7-32-64BIT-/160826243108?pt=UK_Computing_Parallel_Serial_PS_2&hash=item2571fdb824#ht_2280wt_1084

jurij
Associate II
Posted on July 11, 2012 at 00:09

Forgot to ask ... are STM32F4Discovery's UART pins 5V tolerant or not? I was thinking about connecting it to Arduino Mega.

Posted on July 11, 2012 at 00:54

You really want to avoid RS232 signalling voltages, ie 12V. What you want is a USB-to-CMOS-Serial (3V or so), which you can then wire directly to the Discovery series boards.

http://www.ftdichip.com/Support/Documents/DataSheets/DLP/dlptxrx-v14-ds.pdf

These use FTDI chips, but the ones from SiLabs or Prolific work just as well.

Some of the pins are 5V Tolerant (FT), check the chip data sheet or reference manual. From memory, USART1 on PA9,PA10 is, but honestly couldn't tell you if that escapes from your board. I'm using USART3.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jurij
Associate II
Posted on July 11, 2012 at 02:56

Looking at this data sheet: 

http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/DM00037051.pdf

, all USART pins are fault tolerant ... can you confirm this for me, please? 

Does this mean I can connect it the Arduino without problems?

jihlein
Associate II
Posted on July 11, 2012 at 03:16

I'm working on this now, but I've got a question.  Are the USB libraries C or C++?  Reason I ask  is I'm getting an error I don't understand.  The line:

typedef

typedef struct

_USB_OTG_GREGS

//000h

{

{__IO

uint32_t

GOTGCTL

;

/* USB_OTG Control and Status Register 000h*/ 

__IO

uint32_t

GOTGINT

;

/* USB_OTG Interrupt Register 004h*/

Is throwing the error:

Multiple markers at this line

- Syntax error

- expected specifier-qualifier-list

I hope it's some other problem, as TrueStudio Lite only offers the C compiler.

Thanks in advance.

Posted on July 11, 2012 at 04:36

Looking at this data sheet: 

http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/DM00037051.pdf

, all USART pins are fault tolerant ... can you confirm this for me, please?  Does this mean I can connect it the Arduino without problems?

Yeah, looks good, I've got a whole bunch of STM32 series parts rattling around here, the F1's were less complete with the FT pins, always check the specs. 5V != Fault

Arduino should probably work, the STM32's won't output at 5V, so if ~2.9V or whatever VOH is at, is good then you'll be fine. Check VOL/VOH vs VIL/VIH. It won't blow up. Make sure you bond your grounds together between the boards.
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 11, 2012 at 04:43

I'm working on this now, but I've got a question.  Are the USB libraries C or C++?  Reason I ask  is I'm getting an error I don't understand.

I'm building with C, the USB stuff builds with GNU/GCC 4.6.2 and 4.7.1 no problems, ditto Keil 4.53

Perhaps you're missing some include paths in the project? Check for warnings. Or some command line define options.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jurij
Associate II
Posted on July 11, 2012 at 12:37

Thanks!

So - if I use USART3 on STM32F4 and USART1 from ArduinoMega2560, I should connect like this:

STM32F4                                           ARDUINO

PB10 (TX) .........................................  19 (RX1)

PB11 (RX) .........................................  18 (TX1)

GND ..................................................   GND

Question 1: There are more GND (ground) points on each of the boards ... does it matter which I take or not?

Question 2: Is there mistake in 

http://www.st.com/internet/mcu/product/252140.jsp

 data sheet (page 31) ... it says USART 1 and 6 have speeds up to 10.5 Mbit/s, while others only 5.25 bits/s ... bits/s?!