STM32F103 USB Tutorial

If you are reading my posts consistently you must know what i am trying to achieve .So STM32F103 was my final choice because of few reasons

1: I had no experience with USB of STM32F103 nor any other MCU, hence it was a challenge & challenges work great when you are learning.

2:It’s Price was cheap as compared to other solutions and speed was awesome.

3:You can do lot of other projects using this because it’s a MCU.

I was curious about USB and I had read the book called USB complete  months before this project. I had certain experience with V USB & AVRs . So I was kind of ready to fight with USB .

So first I designed the Eagle Library of STM32F103C6  , Circuit diagram of development board and PCB .You can download the files from below.


stm32f103 stm32f103brd

Ok if you are following till now and your board is working  then lets move forward to the  codes. one thing I should admit is that

 USB  is not that simple as it seems .

I downloaded the USB_FS_Library_4.0 from ST .I haven’t linked it because after few days that link will point to error 404 page. I don’t know why but ST’s web devs  always break their links.

After you get the files you need to delete few unnecessary files .Mostly the files that belong to other hardware platforms . however I have done it for you and you can download the complete project below . Then you need to add certain definitions in the configuration panel .


After you define the constants in configuration panel you will see something like below in the platform_cnofig.h. I have used GPIOA Pin 9 as USB pull up Pin . You can use any pin you want .By default its none .remember to connect a wire from your desired pin to pull up register in the schematic and update the .brd file accordingly .



This much is enough for you to make your VCP work .For me it was not enough because i was trying to build a device that can work like team viewer  . To achieve this I had already developed a platform for STM32F4 and  i had also written a c# application that was transmitting Frames of my PC’s screen to STM32F4 .

There are two ways to send inputs to our PC .either i  edit my c#  application to receive inputs over USB and create virtual events on the PC .


Or make my USB device show up as a composite device that will send inputs as real hardwares do . I preferred this one because it involves fight with the Firmware and USB.

I think this much is enough for this post . so far i have covered only 10 % of the project , will post the rest of project soon .keep visiting .





I do what I love. There is a famous quote "Love the process not the product " & I think this is what differentiates developers from consumers .