How to make USB communication with microcontrollers and its details.

By IKTech May 29, 2017

I will try, as much as I know what to share. I hope those newcomers will be able to successfully communicate with microcontrollers via USB communication. I’ll try as much as possible. Please forgive me if I have something wrong.

I think USB serial communication is very good. Because there is no problem with interfacing, as much as RS232 Serial. Speed ​​and much better.USB 1.0 Low Speed-1.5Mbit / second & High Speed ​​-12Mbit / second. This will increase the speed of the USB version, the speed increases. USB5.0 speed 5Gbit / second It’s called SuperSpeed. If you would like more details, please visit Wikipedia’s link.

Anyway, come back to the original words. We support the USB 1.0 that Mikrocontroller will use. Now you can ask questions about when High Speed ​​and when Low Speed When the clock is 6MHz then there will be Low Speed ​​and Clock when 48 MHz will be High Speed ​​.. We will try to communicate at High Speed. But the Clock pulse of 48 MHz is fairly noisy and is more expensive. So we will use the PIC 18f2550 Microcontroller to overcome this problem. Because Microchip companies provide some of their series within the microcontroller, the internal PLL circuit, and PIC 18f2550 microcontroller’s internal internal PLL circuit.


PLL means Phase Locked Loop PLL circuits convert 4MHz clocks to 48MHz clock. So we’ll use that Crystal E to divide it into 4MHz. That means if 12MHz, then 12/3 = 4 MHz. Again if it is 20MHz, then 20/5 = 4 MHz. Because PLL circuits convert 4MHz clocks to 48MHz clock, which is to define during coding.
Phase Locked Loop:

#Creating Source Code by MikroC:

Now open MikroC, click on New Project. You will see the following.

After that, notice the picture below.

1 -> We know PLL circuit only takes 4MHz clock input. So the crystal will divide 12MHz by 3, which will then be converted to 96MHz. If the crystal is 4MHz, then do not take anything.

2 & 3 -> We’re using USB 1.0 and High Speed ​​is at 48MHz. So we have to divide 96 MHz by 2.

4 -> Since using 12MHz Crystal Oscillator, so for the Oscillrtor Selection, select HS Oscillator (HS).

5 -> To make USB communication with PIC microcontrollers, you must enable the Voltage Regulator. This is actually the 3.3 voltage regulator inside the PIC microcontroller. And if it is enabled, the capacitor of 220 nf in the microcontroller vusb pin will be added, you will see the circuit diagram.

Source Code Here:

Unsigned char received [64] absolute 0x500; Unsigned char senddata [64] absolute 0x580;

Int i = 0;
Void Interrupt () {
USB_Interrupt_Proc ();


Void main ()

HID_Enable (& received, & senddata); While (1) { While (! HID_Read ()); For (i = 0; i <64; i ++) {
Senddata [i] = receivedata [i];

While (! HID_Write (& senddata, 64)); 0x7FF]. So the receivedata [64] has been kept in 0x500 of USB RAM, then placed the sendata for the received, and the senddata with the gate 0x580.

2. void Interrupt () {
USB_Interrupt_Proc ();}

Void Interrupt () is a User Define function, which has USB_Interrupt_Proc () inside. Interrupt means to prevent something. The function of this function is to turn the USB connection on or off. When USB_Interrupt_Proc () is enabled, Connection will be OFF and will be on DBBL.

3. HID_Enable (& received, & senddata);

The function of this function is to enable USB 1.0. Which will retrieve the received data on the receivedata and send the senddata data, via USB.

** Note: HID means “Human Interface Device”

4. char HID_Read ();

This function receives the data. Returns 0 if return receives fail, and if not return the character.

While (! HID_Read ());

This means that, continuing to receive the data as long as the data has not been received.

Char HID_Write ();

This function returns data. Returning 0 returns if failing, and if not, returns the number of data that has been sent.

While (! HID_Read ());

This means that continuing the data shedding is as long as the data is not sent.

5. for (i = 0; i <64; i ++) {
Senddata [i] = receivedata [i]; }

This for loop will rotate 0 to 63 times, and the data we receive will send it back to the host, enter the senddata.
Descriptor File Addition Now

Descriptor File: This file will bear the identity of your Microcontroller. The main thing is that this file is your device’s

Manufacture will carry the Product ID, Vendor ID, and introduce the device to the PC.

Let’s show you how to create Descriptor File.

25 thoughts on “How to make USB communication with microcontrollers and its details.

  • Hello there! This is my first visit to your blog! We are a team of volunteers and starting a new project in a community in the same niche. Your blog provided us beneficial information to work on. You have done a extraordinary job!

  • My husband and i felt so delighted when Albert could finish up his studies using the ideas he had in your web page. It’s not at all simplistic just to continually be offering guidelines which some others might have been making money from. And we fully grasp we now have the writer to give thanks to for this. All of the illustrations you have made, the straightforward website navigation, the relationships you will make it possible to foster – it’s many powerful, and it’s letting our son in addition to us recognize that that situation is fun, and that’s especially essential. Thanks for everything!

  • An fascinating discussion is value comment. I think that you should write extra on this subject, it won’t be a taboo subject but generally persons are not sufficient to speak on such topics. To the next. Cheers

  • I am writing to let you be aware of of the great discovery my friend’s child gained visiting the blog. She noticed some things, including what it’s like to have a very effective helping mood to make a number of people with no trouble have an understanding of various extremely tough things. You undoubtedly exceeded people’s expectations. Thanks for rendering these good, trusted, revealing and in addition cool tips on the topic to Jane.

  • Aw, this was a really nice post. In concept I would like to put in writing like this additionally ?taking time and actual effort to make a very good article?however what can I say?I procrastinate alot and in no way appear to get something done.

  • I would like to get across my appreciation for your kind-heartedness for persons that really need help on this important question. Your real dedication to passing the message all through became wonderfully effective and has always encouraged individuals much like me to arrive at their aims. This invaluable report implies a lot to me and even further to my mates. Regards; from each one of us.

  • Howdy! Someone in my Myspace group shared this site with us so I came to give it a look. I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers! Fantastic blog and fantastic design and style.

  • I’m definitely loving the theme/design of your site. Do you ever run into any kind of browser interface problems? A lot of the blog visitors have complained regarding my Arvind Pandit Kansas blog not working properly in Internet Explorer though seems fantastic in Firefox. Have you got any advice to help fix that issue?

  • I want to get across my affection for your kindness giving support to those people that should have help with this important concern. Your very own dedication to getting the message all-around had become quite invaluable and has in every case permitted associates much like me to attain their aims. Your own interesting guidelines signifies this much to me and still more to my fellow workers. Thank you; from each one of us.

  • I used to be very happy to find this net-site.I wished to thanks in your time for this glorious read!! I definitely having fun with each little bit of it and I’ve you bookmarked to take a look at new stuff you blog post.

  • I wanted to draft you this bit of remark in order to give thanks once again relating to the beautiful suggestions you have featured on this site. It is so pretty generous with you to provide freely just what a number of people could possibly have sold as an e book to earn some money for themselves, principally considering the fact that you might well have done it if you wanted. Those creative ideas as well served like the great way to comprehend the rest have similar keenness just like mine to learn more in respect of this matter. I think there are lots of more pleasant times up front for individuals that find out your site.

  • I discovered your blog web site on google and test a number of of your early posts. Continue to keep up the very good operate. I just extra up your RSS feed to my MSN Information Reader. Seeking ahead to reading extra from you later on!?

  • I frequently look over your content carefully. I’m furthermore looking into kmspico, you might discuss that occasionally. Bye bye!

  • I always look over your content carefully. I’m furthermore curious about thai lotto vip tips, perhaps you could write about this from time to time. I’ll be back soon!

  • My husband and i have been now relieved when Louis managed to complete his inquiry out of the precious recommendations he came across from your very own site. It is now and again perplexing to just always be giving for free tips and hints which other people have been selling. Therefore we fully grasp we have the blog owner to give thanks to because of that. The illustrations you’ve made, the straightforward website navigation, the friendships you make it possible to instill – it is most exceptional, and it’s making our son in addition to our family reckon that that theme is satisfying, and that’s unbelievably essential. Thank you for all!

  • Oh my goodness! an amazing article dude. Thanks However I am experiencing subject with ur rss . Don抰 know why Unable to subscribe to it. Is there anybody getting identical rss problem? Anyone who knows kindly respond. Thnkx

  • I wanted to post you one bit of note just to say thanks again about the breathtaking tricks you have discussed in this case. This is really extremely open-handed with you to present publicly precisely what a number of us would’ve offered for sale for an ebook to get some bucks for themselves, and in particular now that you might have tried it if you decided. Those principles also worked to be a fantastic way to know that someone else have a similar keenness similar to my very own to figure out more with regards to this matter. Certainly there are several more pleasurable periods in the future for those who discover your blog post.

  • Thanks a lot for providing individuals with a very remarkable possiblity to read from here. It’s usually so excellent and as well , stuffed with a lot of fun for me and my office acquaintances to visit your web site particularly 3 times weekly to study the fresh tips you have got. And definitely, I am also at all times pleased for the terrific points you serve. Certain 4 ideas on this page are surely the most efficient we have all ever had.

  • An fascinating discussion is value comment. I feel that you need to write extra on this matter, it might not be a taboo subject however generally people are not sufficient to talk on such topics. To the next. Cheers

  • I constantly read through your posts carefully. I’m likewise thinking about intercom phone, maybe you could talk about that sometimes. Have a good day.

  • I definitely wanted to post a simple message in order to say thanks to you for those lovely ideas you are posting at this website. My extended internet investigation has at the end been paid with professional knowledge to exchange with my friends and family. I would believe that many of us visitors are truly endowed to dwell in a good site with so many perfect individuals with helpful hints. I feel pretty privileged to have encountered the webpage and look forward to some more pleasurable minutes reading here. Thanks a lot once again for a lot of things.

  • After research a few of the weblog posts in your web site now, and I actually like your manner of blogging. I bookmarked it to my bookmark web site record and will be checking again soon. Pls check out my website online as well and let me know what you think.

  • I simply needed to thank you so much yet again. I’m not certain the things that I could possibly have followed without the type of concepts shared by you directly on that industry. Certainly was a frustrating concern in my opinion, but considering a new professional way you managed it forced me to weep for joy. I am grateful for the support as well as have high hopes you comprehend what a great job you have been doing educating people with the aid of your blog post. I am certain you haven’t met any of us.

Leave a Reply

Your email address will not be published. Required fields are marked *