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.
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!
''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:
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
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:
Get the USB FS library working.
Set up your configuration descriptors and endpoints etc...
Write application software to do comms on the micro.
Write a windows driver or use an existing driver class.
Install the driver so your device is registered with windows.
Write some PC software to talk at that end.
Have you considered using the UART to talk to the PC?
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!
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
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...