cancel
Showing results for 
Search instead for 
Did you mean: 

USB simple Example

madhu13
Associate II
Posted on August 26, 2010 at 13:03

USB simple Example

9 REPLIES 9
madhu13
Associate II
Posted on May 17, 2011 at 14:04

k...but give me the hint atleast how to start .....this is the fist time i am using and studying controller with USB..I dont have any idea...

ashley23
Associate II
Posted on May 17, 2011 at 14:04

I haven't found one yet, nor have I worked it out myself.  I am 90% there but the examples are too specific and the documentation rubbish.  

I wish they would just make a simple complete example of a read/write pipe for everybody to use!

ashley23
Associate II
Posted on May 17, 2011 at 14:04

I started with the joystick HID demo...  then decided I didn't want HID so went on to create my own descriptors and a .inf file for a WinUSB driver (look it up on msdn).  Then some VC++ code to talk and I am now getting close with the embedded code.  I will admit, the hardest part for me has been the USB FS library!

What do you want your device to do?

madhu13
Associate II
Posted on May 17, 2011 at 14:04

i use Keil IDE,i am not able to understand USB FS library!and as i am starter i just want to write simple code to configure USb to transmit/receive data from/to to the PC. i tried like this to write the reg like this USB->CNTR=0X00000001; but it gives error like this identifier USB is undefined. how to configure the registers.

ashley23
Associate II
Posted on May 17, 2011 at 14:04

Getting USB talking to a PC is very difficult.  Probably one of the most trickiest peripherals to use.  There are heaps of registers to set up and USB will not talk without some sort of communications stack working.  I would strongly recommend using the ST FS library particularly if you are a beginner.  There is a lot of work getting USB working letalone tring to write the USB stack too.  There are other IDEs you can use but I see no reason why you cant use the ST USB stack in the Keil IDE.  To get USB you need to do the following:

  1. Get the USB FS library working.
  2. Set up your configuration descriptors and endpoints etc...
  3. Write application software to do comms on the micro.
  4. Write a windows driver or use an existing driver class.
  5. Install the driver so your device is registered with windows.
  6. Write some PC software to talk at that end.
Have you considered using the UART to talk to the PC?

Andrew Neil
Evangelist
Posted on May 17, 2011 at 14:04

''I wish they would just make a simple complete example...''

The fundamental problem with that, as you now seem to have found, is that USB is

not

simple!

''Have you considered using the UART to talk to the PC?''

That is certainly a lot simpler from the microcontroller's perspective - although some people do still seem to manage to make heavy weather of working with a UART!

Maybe the ''simplest'' (sic?) approach would be to use one of the UART-to-USB adaptors from the likes of FTDI - espeicially if your PC (as is common today) doesn't have any real COM ports!

FTDI do cables which connect direct to the microcontroller's UART (3V or 5V logic levels) at one end, and plug into the PC's USB socket at the other. No special drivers are required, and it appears as a standard COM port to the PC applications:

http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm

Andrew Neil
Evangelist
Posted on May 17, 2011 at 14:04

''can I run HID demo in my board''

That, of course, depends on whether or no you have correctly designed your board for that purpose!

Since you have given no details of your board design, it is impossible to say!

madhu13
Associate II
Posted on May 17, 2011 at 14:04

i downloaded STM32_USB-FS-Device_Lib_V3.2.1 we have designed our own board using STM32F103R8T6 can I run HID demo in my board

ashley23
Associate II
Posted on May 17, 2011 at 14:04

''

I run HID demo in my board''

Why not?  It just uses that state of a few port pins for input or output.  The joystick demo is an even simpler example.  I got it working on the wrong type of development kit.  Just had to alter clock settings to suite my board and swap a few port pins round...