So this tutorial should show you how to get an analog input using a PIC microcontroller (I'm using a PIC16f887) in assembly language. You may have a demo board (which makes programming way easier) just a chip. I'm using just a plain 40 pin chip on a breadboard.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Hardware Setup
-You will need a PICkit programmer
- I am using a PIC chip on a breadboard. If you are using a dev board then you can probably disregard some of this since it should plug right in. I have the following setup:
- Hookup VDD and VSS between PICkit and chip (there may be multiple VDD,VSS pins...connect them all)
- PICkit MPCLEAR to MPCLEAR PIN of chip
- MPLCLEAR PIN of chip has 4.7k-10k resistor (this is important) connected to VDD (if you are just using a chip only)
- PGD pin of PICkit to PGD on board
- PGC pin of PICkit to PGC on board
- PGM pin on PICkit is left unconnected
Follow the attached diagram to hookup the the entire circuit.
Step 2: Software Setup
You need MPLAB X IDE installed if you don't have it already.
- Open MPLAB
- File->New Project
- Microchip Embedded->Standalone Project
- Select Your Chip from the list (mine is a 16F887)
- Select PICkit under the hardware tools
- Select mpasm
- Set your project name and save locations
Now that you created the project, let's configure some of the properties
- In the project tree that just got created on the left, right click the project and select properties
- Select PICKit on the left hand side
- Select power from the dropdown list
- Check the power the target device and set the voltage level 3.375
- In the project tree, right click the source folder and add a general asm file
- Open the .asm file and past the code from the attached .txt file