Mplab Presentation

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Hello good morning, im *ngalan nimo* and i am here to explain the simulation we

presented to you last practical. In this simulation, we used switch as our input
and LED as our output.

> Today, we will present the simulation of an input/output program using MPLAB and
Proteus. In this simulation, we used SWITCH as our input and LED as our output.
First, we begin the simulation by writing our source code.

> In the first line, we used an include directive. That is why we have included the
library of pic16f877a. Secondly, we declared some file address or Special Function
Registers. The first one is the Status Register which has a file address of 0x03,
meaning it is located in address 3. We chose PORT B and Port D for the input and
output ports. We declared PORT B as our output port with a file address of 0x06 and
Port D as our input port with a file address of 0x08. We also chose TRIS B, which
is the register of PORT B and TRIS D, which is the register of PORT D. PORT B is in
file address 6 located in Bank 0, so EQU 0x06 and PORT D in address 8, meaning EQU
0x08. Then the TRIS B has an equivalent file address of 0x86, also located in Bank
1, and TRIS D has an equivalent file address of 0x88.
We assigned pins to the ports where we will connect the LED as our output and the
Switch as our input during this phase. First, the LED is connected to PIN 4 of PORT
B, so EQU 0x04 which is the 5th pin of Port B, and then the Switch is connected to
PIN 1 of PORT D, so EQU 0x01 which is the 2nd pin of Port D.

> To initialize the program, we used the directive org 0x0000 that serves as an
indication that the program will start and then goto Start. Then banksel TRIS B,
this directive indicates if we can proceed to the specific bank and since the TRIS
B is located in Bank 1, so this means we already arrived in Bank 1, so TRIS B.

> Then the bcf TRIS B is where we clear TRIS B which is the output, and then the
bsf TRIS D which is considered as our input. We go back to bank 0, so banksel PORT
B and then bcf PORT B, LED so we clear the LED first, which means the LED is turned
off before starting the simulation. Then next is the btfss, which means it sets
first the value and then it will directly skip. So, for instance, the value is 1,
so we proceed to goto LEDOFF, then it will skip goto LEDON, then we clear the
output which is the LED. Whereas, if the value is 0, that means we proceed to goto
LEDON then bsf LEDON, and then the LED will turn on since the LED has already a
small value which is 1, and the LED will then be cleared. And then next is goto
AGAIN.

> So, this will be repeated if the simulation is still going on or running. And
then lastly, we used the directive end in order to end the program. After that, we
build the project, and if there is no error occurring, it means the build is
successful. If the process of building the project went adequately, then we proceed
to proteus.

> This is our schematic diagram, we used a crystal oscillator with 16-megahertz
value, 2 capacitors with 22pF value, 2 resistors with 470 ohms value (the first one
is connected to switch and then the other one is connected to LED), and then we
used switch to represent our input which is connected to PIN 1 of PORT D and LED as
our output which is connected to PIN 4 of PORT B. Our input is located in PORT D,
and then the output is located in PORT B. Then we upload the hex file by double-
clicking the PIC16f877A microcontroller and open the hex file then click ok. After
that, we can run the simulation.

> Therefore, since the condition of our Switch is open, our LED is turned off, but
if we close the Switch, our LED will turn on. Then it will turn on and off
repeatedly while the simulation is still running.

You might also like