cancel
Showing results for 
Search instead for 
Did you mean: 

Help transfering data to PC

pumzele
Associate II
Posted on December 12, 2011 at 08:47

Hello there,

I desperatly need help getting data from my stm32f4 to my pc.

I was thinking of using the OTG and set it up as a keyboard and transfer the data accross like that but it seems like a huge mission to transfer data. On older chips they just had an FTDI chip which was very easy to set up and use. Does anyone maybe know of an easier way to transfer data over to my Computer using the built in micro usb? Some sample code will also help a lot as the otg seems very complex

#transfer-data-using-usb #stm32f4discovery-usart-serial-us #vcp(virtual-com-port)-stm32f4 #stm32f4-usb-cdc
26 REPLIES 26
raffael
Associate II
Posted on December 20, 2011 at 16:25

Hello,

Have you made any progress implementing communication using the micro USB?

I'm wondering because I should use USB too, later in my project.

(Unfortunately I didn't have time to try implementing USB communication yet.) 

Best

rm23
Associate II
Posted on December 20, 2011 at 22:31

It is not in theory difficult, but there is little documentation, and what is claimed to be working, often isnt!.

eg To start, I am just trying to get the host (PC XP) to recognise 2 HID devises.   Using JvHidController class (Delpho) - just an interface to HID.dll (windows), I can see and 'CHECKOUT' ie gain control of a single US=B HID device (a PSR3 game controller £10 is one!). BUT I seem unable to initiate a direct (unparsed) 48 byte record from it.

You may be asking what this is to do with the STM32F4, but until I have a source controllable Host program, what chance in hell do I have of debugging a USB HID comms program to the STM32F4??????????????????????????????????????????

tony2399
Associate II
Posted on December 22, 2011 at 02:49

Hi all,

If you're only looking to transfer small amount of data from the PC to the Discovery, I suggest you try the semi-hosted I/O library of your toolchain/IDE, which allows limited I/O operations through the debug link.

Also, I've had success with hooking up--well, more like ''hacking up'' the SD controller using an adapter to read from microSD cards. I'm pretty satisfied with the throughput, even using just the 1-bit protocol (I get ~2-3MB/s). There's example code from the

STM324xG-EVAL

peripherals library, you just need to tweak some of the pinouts/clocks to fit the Discovery board.

BTW if you're just looking at a few kilobytes then just convert to C arrays and link them to your program code.

jdsotack
Associate II
Posted on January 03, 2012 at 20:35

Your IDE probably gives you a way to save the contents of target memory to a file.  I have done this successfully.  You could save the memory containing your ADC samples to a file on your PC.  You could then write a simple PC application to covert the file into the form you need.

John. 

pumzele
Associate II
Posted on January 06, 2012 at 10:55

Your Idea sounds very cool. Do you know how I could save the data to file? I.m using Keil uVision4

Posted on January 06, 2012 at 16:45

Your Idea sounds very cool. Do you know how I could save the data to file? I.m using Keil uVision4

 

Presumably by using SAVE in the debugger command line window

SAVE TEST.HEX 0x20000000,0x20003FFF

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

Update:

I have been modefying the ''Virtual Com Port'' code for the STM32F2-evaluation board.

So far no luck. The closest I got was for windows to give an error message ''USB device not recognised''.

If I get it working I will post the code up on here. any help would be appreciated

raffael
Associate II
Posted on January 09, 2012 at 15:24

Hello Daniel.

I started studying the VCP today. I will also try to modify the STM32F2 example code.

It might be useful if you could give some details on what you did.

pumzele
Associate II
Posted on January 10, 2012 at 08:01

Well like I said I haven't got it working yet and am going to throw in the towel (unless I get it working today) as today is my last day of vacation work. But I can tell you what I did.

Make a new project including all the standard libraries and drivers you need from the stm32f4.

Then compare to the stm32f2 and see which files you still need. Copy all the files you need into your new project and start modifying the code to work with the stm32f4 that means for example changing #include  ''stm32_eval.h'' to #include ''stm32f4_discovery.h''. Also some of the pins have different names so when ever it won’t compile because undefined, trance what it refers to in stm32f2 and change it appropriately. I finally got mine to compile but I must have missed something or not changed something properly as windows does not recognise it. But then again it is my first time working with USB,  first time with a stm chip and first time using kiel compiler. You'll most probably find the answer quicker. If you do, please post it up on here. If you want what I got so far (compiling but not working) let me know although I think it would be better you do it yourself as then you know what has been changed and done. It might be wise to do it systematically because I didn't document all the changes I did and that is most probably why I am stuck now
raffael
Associate II
Posted on January 16, 2012 at 13:55

Ok, Finally Windows recognizes the STM32F4 Discovery as Virtual Com Port when I plug it to my PC.

Basic Communication works too. (Toggling Led when reveiving Data)

If anyone is interessted in USB VCP: I just discovered this Project Page:

STM32F405 USB serial example running on STM32F4-DISCOVERYBOARD

''https://www.das-labor.org/trac/browser/microcontroller/src-stm32f4xx/serialUSB?rev=5213''