Circuit Setup / MPLAB X IDE - Part 4 Simple Microcontroller (PIC10F200)
This is the last microcontroller tutorial before we load some code on the microcontroller and start actually doing things! It’s very exciting. In this tutorial, I will provide some final practical information needed for the microcontroller examples to work. It will be divided into two parts: first, schematic of the circuit, and second, to create and setup a project in the MPLAB IDE.
IDE stands for Integrated Development Environment and is there to make your life easier when writing code, programming your microcontroller, and debugging issues.
The schematic diagram of the first circuit we’ll be doing together is shown in Figure 1.
Yes, my dear readers! No Fritzing here, only a serious, black and white schematic diagram. We’re going to learn Assembly language so we need to be able to read normal schematic diagrams too. It’s good to start reading real schematics with something simple like this and practice moving it to a breadboard before the circuits start to get really complicated.
As you can see in Figure 1, the heart of the schematic is our microcontroller, the PIC10F200, called here DD1. The other mandatory part is the microcontroller programmer/debugger, here called X1. I showed the pinout of the PICKit programmer, so if you have the same one, just use the pin numbers from Figure 1. If you’re using a PICKit 4 programmer, you’ll have an extra two pins at the end (7 and 8), you can just ignore them and not connect them to anything.
We will connect two LEDs (LED1 and LED2) and two tactile switches (SW1 and SW2) to our microcontroller. R1 and R2 limit the current of the LEDs. Unless you want to destroy your LEDs, R1 and R2 are mandatory. If you’re not familiar with why you need resistors with your LEDs, check out our tutorial on LEDs here. The resistors R3 and R4 are optional as we install them just to protect the device from potential short circuits. As you are not confident with Assembly programming yet, it’s possible you could set the GP0 output as high, and short the pin by pressing SW2.
Another thing you need to remember, and is very important when you develop your own circuits, is that the PIC10F200 supports only high-voltage programming. This means that during microcontroller programming, about 10-11 V is applied to pin GP3/VPP. So if there is any voltage-sensitive device connected to this pin, it can be damaged. Thus, you need to disconnect it during the microcontroller programming process. You will likely make this mistake once and then remember it forevermore. Such is life playing with electronics.
You may assemble the schematic using a breadboard and male-to-male dupont connectors. Or you can design a PCB and solder the parts on, if you have such skills or desire to practice them. In that case you may use the PIC10F200 in the 6 pin microcontroller SOT23 package, or you could keep the 8 pin microcontroller DIP8 package just to make the soldering easy. It’s up to you!
That’s it for the schematics. Now, we move on to creating the project in the IDE.
Setting up a project in MPLAB IDE
I’m working under the assumption that you have assembled your circuit and successfully installed MPLAB on your computer. Next, let’s setup the project!
MPLAB IDE 8.76 Setup
If you have installed MPLAB 8.76 then do the following:
1. Run the MPLAB IDE
2. In the main menu select “Project” -> “Project Wizard”
3. In the opened window, click “Next” to see the following window:
4. Select PIC10F200 device from the drop-down list and click “Next”. Make sure that in the next window “Microchip MPASM Toolsuite” is selected as the Active Toolsuite.
5. Click “Next”. In the following window select “Browse…” and select the location of your project, and specify a project name. Then click “Save”. Finally you will have something like this:
6. Click “Next”, skip this step as we are not going to add anything to the project.
7. Click “Next” again. And finally click “Ready”. You will see the project structure window opened in the main window of the MPLAB IDE:
8. Now we need to add the file where we will write our code. So from the main menu select “File” -> “New” to see a blank file:
9. Save this file through main menu “File” -> “Save As…” with the name “main.asm”, and don’t forget to set the check “Add File To Project”:
10. Make sure that the file has appeared in the project structure:
11. Now we have created everything to start writing our code which we will do in the next tutorial, but for now we need to setup the programmer.
12. I’m assuming that the schematic, shown in Figure 1 is already assembled. So now you may connect the programmer to your PC through the USB port. I will show how to setup a programmer on the example of PICKit3.
13. In the main menu select “Programmer” -> “Select Programmer” -> “PICKit 3”
14. You will see a Voltage Caution window that informs us that if you apply 5V to 3.3V device it can be damaged. Click “OK” as PIC10F200 works in the 2.0 – 5.5V range, so we’re good!.
15. The first time you might see the following error:
16. It means that the programmer can’t see the microcontroller. This happens because, by default, the programmer doesn’t provide power to the microcontroller. So we need to set it up. Select the main menu “Programmer” -> “Settings”, and in the opened window select “Power” tab and set the check at “Power target circuit from PICKit 3” and keep the voltage at 5.0V:
17. Click “OK”. Then you’ll see the Voltage Caution again, and again, click “OK”.
18. Then in the main menu select “Programmer” - > “Reconnect” and make sure that the error is gone:
Now everything is ready, and if you are using just MPLAB 8.76, you’re all done and you can move on to the next tutorial where we will go over how to program microcontroller, actually get to do the microcontroller programming, and then we'll be up and running!
MPLAB X IDE Setup
If you want to know how to setup the MPLAB X IDE then let’s get started!
If you have installed MPLAB X then the sequence of actions will be a bit different from the MPLAB 8.76 version:
1. Run the MPLAB X IDE. My software version is 5.10 so if your version differs then your operation sequence may be different.
2. Connect your programmer with the attached circuit shown in Figure 1 to the USB port of the PC.
3. In the main menu select “File” then “New Project…” and look at the project wizard:
4. Select “Standalone project” and click “Next >”. In the next window select Family as “Baseline 8-bit MCUs (PIC10/12/16)” and Device as “PIC10F200” apparently:
5. Click “Next >” and skip the selection of the Debug Header:
6. Click “Next > ” and select PICKit3 (or whichever programmer you use) in the list:
7. Click “Next >” and select the “mpasm” as a compiler:
8. Click “Next >” and write the name of your project and select its location, I called it “First”, you can call it whatever you want.
9. Click “Finish” to close this window and create the project.
10. You may notice that your project is now in the Projects list in the left part of the window:
11. Now we need to create the file where we will write the code. So in the main menu select “File” -> “New File…” and see the following window
12. Select “Assembler” in the Category and “AssemblyFile.asm” in the File Types:
13. Click “Next >” and type file name as “main”, leaving the file location at the default:
14. Click “Finish” to close this window and create the new file. Make sure that this file has appeared in the list in the left part of the window:
15. Finally, we need to setup the programmer to provide the voltage to the circuit. In the main menu select “File” -> “Project Properties (xxxx)” where xxxx is the name of your project. You should see the following window:
16. In the left list “Categories” select “PICKit 3” (or whatever your programmer is):
17. In the right part select Option categories as “Power” and set the check “Power target circuit from PICKit3”. You can keep the voltage at 5.0V as PIC10F200 supports it:
18. Then click “Apply” and then “OK” to close the window.
That’s it! Now your hardware and software are ready, and you can start to write your program. We’ll do that in the very next tutorial before finally doing the microcontroller programming. And, if you haven’t already, before moving on, make sure to assemble the schematic according to Figure 1 and setup your IDE according to the instructions above. I look forward to the next microcontroller tutorial - this is where it starts getting really exciting.
- 185 Tutorials
- 7 Textbooks
- 12 Study Guides
- 31 Tools
- 82 EE FAQs
- 295 Equations Library
- 185 Reference Materials
- 91 Glossary of Terms
Friends of CircuitBread
10% Student Discount for Components
Product Samples Upon Request
Power Supply Related Technical Resources + 1 Perk
Get the latest tools and tutorials, fresh from the toaster.