Application 1 - Running Led: Experiment 4
Application 1 - Running Led: Experiment 4
EXPERIMENT 4:
B. EQUIPMENTS REQUIRED
C. THEORY
The derives its timing from a 4-phase clock (clock cycle). Each word of instruction needs 4 clock cycle to
be executed. Time needed to complete an instruction during execution can be calculate using the formula
given below:
1 JKE/POLISAS/E4160-exp. 4/JUN2011
E4160 SISTEM MIKROPEMPROSES & PENGAWAL MIKRO
NO D. PROCEDURE
Device: PIC16F877A
Active Toolsuite: Microchip MPASM Toolsuite
Project Name Lab4
Project Directory <your own choice>
2 Open a new file by clicking File> New, and start to enter into it Program Example 4.1. After a few lines
save as this program as ProgramLab4.asm
3 Continue entering the code. When complete, go to the Project menu again, click Add Files to Project...
and select the one you have just saved.
5 Download ProgramLab4.hex file into PIC (SK40C). After finish downloading turn off SK40C.
NO E. RESULT
1
(ON = 1, OFF = 0)
LED
RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0
Output
state
1
2
3
4
5
6
7
8
Table 4.1
(8 marks)
2 JKE/POLISAS/E4160-exp. 4/JUN2011
E4160 SISTEM MIKROPEMPROSES & PENGAWAL MIKRO
NO F. QUESTION
1. Draw the flowchart and for time delay subroutine of Program Example 4.1
(11 marks)
NO G. DISCUSSION
1.
(6 marks)
NO H. CONCLUSION
1.
(5 marks)
3 JKE/POLISAS/E4160-exp. 4/JUN2011
E4160 SISTEM MIKROPEMPROSES & PENGAWAL MIKRO
APPENDIX
START
D1=0X20
D2=0X21
D3=0X22
PORTB=OUTPUT
CLEAR PORTB
(ALL LED OFF)
PORTB = ‘00000001’
(LED1 ON)
DELAY
RLF PORTB
(LED2 ON,LED1 OFF)
DELAY
RLF PORTB
(LED8 ON,LED1,2,3,4,5,6,7 OFF)
DELAY
4 JKE/POLISAS/E4160-exp. 4/JUN2011
E4160 SISTEM MIKROPEMPROSES & PENGAWAL MIKRO
;--------------------------Runlight1 ----------------------------
PROCESSOR 16F877A
#INCLUDE <P16F877A.INC>
__CONFIG 0X3F32
;Subroutine -----------------------------------------
5 JKE/POLISAS/E4160-exp. 4/JUN2011