Documente Academic
Documente Profesional
Documente Cultură
We can use CoreChart software to program the PIC and make the test LED turn on and off.
Test LED is connected to Port B7 via a current limiting resistor.
39 R
390Ω
Chip Diagram
B7 B6 B5 B4 B3 B2 B1 B0
0 0 0 0 0 0 0 0 Port B
Register
390Ω
3. Open CoreChart.
5. Save as Lab1.
Three icons will appear at the screen. Below are the icons and their functions:
Beginning of program.
End of program.
Setup Subroutine. The routine is to configure PIC16F819
to use its internal clock (8 MHz).
The “Setup” subroutine performed two important tasks before the program is run:
1) The microcontroller internal clock is set to run at 8MHz with these instructions:
2) The “DigitalPort” subroutine sets all PORTA pins from the default “analogue
ports” to “digital ports” with these instructions:
6. In this exercise, we will use Set/Reset icon to turn on the yellow LED.
8. Assign Set PORTB Bit7 ON as shown and place it after Icon 2 by clicking on the
little black arrow under Icon 2.
In this part, PORTB memory register become:
B7 B6 B5 B4 B3 B2 B1 B0
1 0 0 0 0 0 0 0 Port B
Register
390Ω
Notes: We have assign Set Bit 7 is ON which means Bit 7 is ONE thus LED is ON.
9. Double click at Start icon, assign PIN 13 (RB7) as output pin (arrow pointing out
from IC).
If we have tick the statement, it means that we assign the program to be run
after we press the Push Button first. If we un-tick the statement, program will
be automatically run when we ON the power switch without need to wait for
press the Push Button.
eLab16m
Ribbon cable
USB Cable
11. Load the program by click on “Tools” drop menu and then click “Send to Chip”. The
step can also be done with the F9 function key.
When the program is successful download to the chip, a GREEN status bar will appear.
If it RED, check that all the cables are connected correctly and power on the eLab16m is
turned on.
12. Press the push button and LED will turn on.
1. Open Lab1.
2. Change Set PORTB Bit7 ON to Set PORTB Bit7 OFF.
3. Load the program.
4. We will see the LED is off.
Now, Port B memory register become:
B7 B6 B5 B4 B3 B2 B1 B0
0 0 0 0 0 0 0 0 Port B
Register
390Ω
Notes: We have assign Set Bit 7 is OFF which means Bit 7 is ZERO, thus LED is OFF.
1. Open Lab1.
2. Use Set/Reset Icon to flash the yellow LED. Make it on, off, on, off.
4. Switch on the switch button. Can you see the LED flashing?
Notes: The execution from one instruction to another instruction is at high speed
which is about 0.5µs. Thus, we cannot see the LED flashing. We need to include
delay program in order to see the LED flashing.
Refer Appendix.
1. Open Lab1.
Assign W
Until now, your program
should look like this.
4. To get delay subroutine, click on the subroutine icon at Icons box. Subroutines box as
below will appear and click “OK”.
Select W=255
.
Delay subroutine.
7. Double click on the subroutine “DELAY” to open and view the coding of the
subroutine.
Delay Subroutine