Turn off Led using PIC16f877a with Assembler Code

Start making a simple program in which we in assembly code using PIC 16F877A to turn on and off an LED by pressing a button as shown in the diagram.
We will use two ports of the PIC 16F877A, port B and port D, declare the B port as input and the D port will be configured as an output. In the graph we can see that the pin RB0 is set button and a resistor in a pull-up configuration, when you are not pressing the button it gets a high (5V) to the RB0 input and when pressed he gets a level low (0V). In the output RD0 to turn on the led its output should be at a low level so when developing the program in assembler we test the pin B0 and if a high level put a high value on the output RD0 that will keep off LED, otherwise put a low value on the output RD0 which will cause the LED lights.

ASSEMBLER PROGRAM FOR PIC 16F877A
To make the program use the MPLABX 2.0
Open the IDE MPLABX program.
  • We click file, select New Project ...
  • In window "Select Project" emerging select "Microchip Embedded" and "Standalone Project" then click on "next".
  • In the window that pops up "Select Device" leave the box "Family" in "all families" and the box "Device" digitamos "PIC16F877A" then press "next".
  • In the "Select Tool" window select "Simulator" and we click "Next".
  • In "Select compiler" select "MPASM (v5.54) [...... ..".
  • Now select the location and name of the project.
  • After creating the project and select New File window "Select File Type" appears and select "assembler" if not listed select "Other" a new list where you can select "assembler" appears.
  • Then you can put nonbre to File and select a folder within the project and ready.
Now it's time to write the program in assembler that is recorded in the pic 16F877A is as follows:

Comments

Post a Comment

Popular posts from this blog

N-Channel MOSFET High-Side Drive: When, Why and How?

Using the high-low side driver IR2110 - explanation and plenty of example circuits

Using the SG3525 PWM Controller - Explanation and Example: Circuit Diagram / Schematic of Push-Pull Converter