Analog Input Using PIC Microcontroller (assembly Language)

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.

Step 1: Hardware Setup

-You will need a PICkit programmer

  1. 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:
  2. Hookup VDD and VSS between PICkit and chip (there may be multiple VDD,VSS pins…connect them all)
  3. PICkit MPCLEAR to MPCLEAR PIN of chip
  4. MPLCLEAR PIN of chip has 4.7k-10k resistor (this is important) connected to VDD (if you are just using a chip only)
  5. PGD pin of PICkit to PGD on board
  6. PGC pin of PICkit to PGC on board
  7. 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.

  1. Open MPLAB
  2. File->New Project
  3. Microchip Embedded->Standalone Project
  4. Select Your Chip from the list (mine is a 16F887)
  5. Select PICkit under the hardware tools
  6. Select mpasm
  7. Set your project name and save locations

Now that you created the project, let’s configure some of the properties

  1. In the project tree that just got created on the left, right click the project and select properties
  2. Select PICKit on the left hand side
  3. Select power from the dropdown list
  4. Check the power the target device and set the voltage level 3.375
  5. In the project tree, right click the source folder and add a general asm file
  6. Open the .asm file and past the code from the attached .txt file


Step 3: Wrap-up

Assuming there was no copy and paste formatting errors and you changed the appropriate code if you use a different microcontroller, you should be ready to hit the green play button.Check this out if you want to see how to essentially do this in C instead of assembly while still using MPLAB. There is also a good explanation of some of the special function registers (SFRs) used in analog to digital conversion in it as well.

Source: Analog Input Using PIC Microcontroller (assembly Language)

About The Author

Muhammad Bilal

I am a highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.