Getting Started With PIC Microcontrollers
by Thundertronics in Circuits > Electronics
7829 Views, 11 Favorites, 0 Comments
Getting Started With PIC Microcontrollers
PIC microcontroller is the most famous microcontroller for beginners and professionals alike. It is good and easy to use.
To use and program it you must have these stuff (which will be explained later):
1- The microcontroller itself.
2- IDE.
3- Compiler.
4- Programmer\Debugger.
5- Other stuff.
PICs are divided into families such as PIC10, PIC16, PIC24, PIC32 and so on. As of CPU architecture, they are divided into 8-bit, 16-bit, and 32-bit microcontrollers.
The chip we will be using during this course is PIC16F877A which is an 8-bit microcontroller and belong to PIC16 family.
Video Tutorial
Everything to learn is in this video that I made, the course will be by video:
Be sure to subscribe to my channel VEGEteK on youtube to get latest videos of this course since they are posted there before here.
PIC16F877A Microcontroller
This is the most famous one and you will find tons of tutorials and community projects for it.
Product link: http://www.microchip.com/wwwproducts/en/PIC16F877A
Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/39...
Buy from Aliexpress: https://www.aliexpress.com/w/wholesale-pic16f877a....
Buy from Digikey: https://www.digikey.com/products/en/integrated-cir...
This device is not recommended for new designs but we will be using it due to its wide spread and easiness. If you consider a modern replacement, then go with PIC16F18877. However, this course doesn't force a certain part but encourages you to learn how to use ANY part. So if you got any PIC MCU, then that is good enough.
MPLAB X IDE
An IDE is Integrated Development Environment, which is a computer software that allows you to write code for your PIC microcontroller. It allows testing and debugging the code as well as simulation and other great stuff.
MPLAB X is the official IDE from Microchip which is not only free but works fine and stable, no need to get any other tool.
Product page: www.microchip.com/mplab/mplab-x-ide
Download: click here or go to product page then to "Downloads" section if you want other OS versions.
It is worth mentioning that they have a cloud online version of MPLAB X called MPLAB Xpress. However, I only recommend getting the full version above.
Also, when you finish installing MPLAB X, be sure to get MPLAB Code Configurator because it is nice and useful later on.
XC8 Compiler
A compiler is the software tool that converts your code to machine language which is the only language microcontrollers understand.
Your code will be in C language which is a high level language and therefore you need C compilers to be integrated with your IDE to be able to produce what is called the .HEX file. This is a file that has only 0s and 1s which is called "machine language", so the compiler converts your C code to that language of 0 and 1 storing it in a .hex file.
Microchip bought XC compilers and thus they are the official compilers for PIC. There are many other third party tools available but you don't need them. XC8 is for 8-bit and XC16, XC32 for 16 and 32 bit MCUs.
XC compilers: http://www.microchip.com/mplab/compilers
Download XC8: Here.
XC8 documentation: from compilers page, go to "Documentation" tab.
Important note: you will find lots of third party tools but don't use them. Some of them are good and easy to use but you will be stuck with them forever and won't be able to work with anything else! While if you work with the official tools that all people work with, then you are using the industry standard tools and you will fit in any company or any job. This goes for compilers, programmers, or anything!
PICKit 3 Programmer
PICKit 3 is the official programmer and debugger from Microchip. It is around 40-50$ which is a very cheap price for the features that it has.
It is a serial programmer using In-Circuit Serial Programming (ICSP) which allows you to program your PIC while it is at the breadboard, so no need to take it out then plugging it in a programmer socket then get it out again... those are called parallel programmers and they are no longer in business. You must get PICKit 3 or other serial programmers from Microchip only, no third party regardless of anything. PICKit 3 is not a production programmer so it is recommended to get other programmers if you are going to program thousands of microcontrollers for your company (which we won't in this course xD).
Product link: http://www.microchip.com/pickit3
Buying it: I suggest posting a thread in EEVBlog forum here stating that you wanna buy one, then sellers will offer you just like I did here and I got it fast with very low price!
Beware that there are many clones of this one so be sure to buy from a genuine source.
IMPORTANT NOTE: DO NOT GET ANY THIRD-PARTY PROGRAMMER UNDER ANY CONDITION!
Other Stuff
You are pretty much finished here but you need somethings like: Breadboard, crystal oscillator, capacitors of all types, voltage regulators...etc. Any general parts will do!
PIC16F877A can have 20 MHz crystal oscillator but you can get 4 MHz or 8 or 16... Anything works. PIC16F877A works with 5v so you need a 5v regulator such as 7805 or better if you have a lab power supply. If you don't, you can always watch my tutorial about making one with cheap and available components.
Now you are ready to program PIC MCUs! so future tutorials will build on this one assuming you have required components.
Be sure to subscribe to my channel VEGEteK to get future videos, and this playlist will hold this course's videos.