Electronic – C/C++/C# programming for interfacing USB to PIC microcontroller

microchipmicrocontrollerpicprogrammingusb

I am a computer sciences student looking to do some PIC microcontroller programming for some small home projects . I am fluent in C/C++/C#/Java and i also have an understanding of programming microprocessors(ALP – the 8086 ) . I plan on building a USB interface to control some lighting and a motor in one of my projects . I have the circuit components and the layout planned out . I have the PIC 18f4550 in mind and I have already downloaded the libraries from the microchip website . The only problem is I don't know what code to write for this . The libraries are huge and I don't really need to go into all the details(that's what I think) . I tried finding other resources but it appears that the PIC is old and most of the links off of Google have only been dead ends . Does anyone know of a blog , a video , or anything that could help me get started ? I'm hoping it's possible to do this using one of the languages I mentioned above .

Best Answer

You should first take a look at the examples provides with the Microchip USB Framework (part of the Microchip Application Libraries). The docs give some descriptions on the individual demos. The helpfile itself is in my opinion a little bit hidden, but you can find it at <YourInstallLocation>\Microchip\Help\MCHPFSUSB Library Help.pdf

To get started and depending how you want your device to appear on the host pc, I would go through the code of the following demos:

  • Device - CDC Basic Demo
  • Device - HID - Custom Demo

Both state in the description that they are able to run on the 'Low Pin Count USB Development Board', which is using a PIC18F14K50. The PIC18F4550 should be similar enough to allow you to transfer most, maybe even all, of the code.

Another approach, as kenny recommended, is to use a IC that handles most of the USB stuff for you. A popular choice are the ones from FTDI. When you take the FT232R, you hook the UART of your microcontroller to the IC. Writing code to transmit / receive data is now much simpler.

Similar to the FT232R is the IC MCP2200 manufactured by Microchip. Which one you choose is a matter of taste (and maybe driver support).