Академический Документы
Профессиональный Документы
Культура Документы
MICROPROCESSOR SYSTEMS
Semester 2, Academic Year 2014/2015
NAME
TITLE
: 02
TABLE OF CONTENT
1
NO.
CONTENT
PAGE NUMBER
1.
Project Specifications
3-4
2.
5-7
3.
4.
Conclusion
5.
Appendix
10-19
Project Specifications
BLOCK DIAGRAM
PORT B
PORT D
RESET
PAUSE
SIX 7-SEG
DECODER
PORT B
PORT E
RESUME
SIX
SEVEN
SEGMEN
T LED
DISPLAY
PORT B
PORT F
6 TIME
ADJUST
BUTTON
PORT
G
PORT C
PORT H
List of components
1. 6 7-segment display (cathode)
2. 6 decoders (7447)
3
Operation
Initially the displays are set at 00:00:00. 6 buttons will be placed at PORTC. Each pair of
buttons will control hours ,minutes and seconds respectively. The buttons are used to increase
the respective value of displayed time.
Flowchart
DIGITAL CLOCK
TRISE,F,G=0
START
TRISB=I,
Initialize resume button at
INT0
initialize pause button at
INT1
initialize timer 0 as 1 second
counter
set second=0x20
set minutes=0x21
set hours=0x22
A
second 1= second
1+1
1 sec
delay
display on
second 1
NO
is
second 1>9
YES
second2=second
2+1
1 sec
delay
display on
second 2
isNO
second 2>5
second2=0
second=1
1 sec
delay
A
min1=min1
+1
display on
Minute 1
is min
1 sec
delay
Display on
minute 2
1>9
is min
no
2>5
min 1= min
YES
1 sec
display on hour 1
delay
min 2=
0
min1=
0
sec1=
hour1= hour
1+1
is
hour
1>4
NO
A
1sec delay
display on
hour2
YES
NO
is
hour 2=2
1 sec
delay
YES
display on hour
1
is
NO 1>9
hour
YES
min2=0
min1=0
sec 1=0
sec 2=0
hour1= 0
hour2= hour
2+1
1 second
delay
display
hour2
A
Two interrupts has been used to pause and resume the time. The pause button is used
to pause the running time. The time can only be adjusted after the running time is paused. The
resume button is whereas is used to resume the running time after the time has been set.
One reset button has been used to reset the running time. When this reset button is
pressed it is programmed to reset the running time to 00:00:00.
Six different button is used to adjust the display of each seven segment led display.
This button is used to adjust the time respectively. User must pause the running time in ordr
to use this button to adjust the time. Then time can be resume back using the resume button.
Conclusion
The objective of this project to build a digital clock has been meet. Besides that we
also has used 9 buttons to pause, resume, reset and adjust the time. The specification of this
project has been meet as the 24 hours digital clock is running successfully. There are several
8
modifications that can be done to improvise this digital clock. These modifications can
increase the functions of this digital clock making it technologically competent.
One of the ways we can improve this digital clock is by changing the 24 hours system
to 12 hours system. This can be done by using different sets of display which will display
a.m. and p.m.. This modification will enhance the precision of the digital clock as well as
make it easier to comprehend the timing. Besides that, we can also add settings to display the
date and day to incline the functionality of the digital clock. Last but not least, the program
can be altered to be used as timer.
Appendix
#include <P18F8720.inc>
org 0x00
goto start
org 0x08
goto ISR_RESET
org 0x18
goto ISR_PAUSE
start
res1
rcall DELAY_1s
10
incf PORTD,F,A
movlw 0x09
cpfsgt PORTD,A
bra res1
bra res2
res2
incf PORTJ,F,A
clrf PORTD
movlw 0x05
cpfsgt PORTJ,A
bra res1
bra rem1
rem1
clrf PORTD
clrf PORTJ
INCF PORTH,F,A
movlw 0x09
cpfsgt PORTH,A
BRA res1
BRA rem2
rem2
clrf PORTD
clrf PORTJ
clrf PORTH
INCF PORTG,F,A
movlw 0x05
11
CPFSGT PORTG,A
BRA res1
BRA reh1
reh1
clrf PORTD
clrf PORTJ
clrf PORTH
clrf PORTG
movlw 0x02
cpfseq PORTE,A
bra nope ;H2 is not 2
bra yes ;H2 is at 2
nope
incf 0x12,F,A
movff 0x12,PORTF
movlw 0x09
cpfsgt 0x12,A
bra nope2 ; H1 is less than at 9
incf PORTE,F,A
clrf PORTD
clrf PORTJ
clrf PORTH
clrf PORTG
clrf PORTF
clrf 0x12
bra res1
nope2
12
clrf PORTD
clrf PORTJ
clrf PORTH
clrf PORTG
bra res1
yes
incf 0x12,F,A
movff 0x12,PORTF
movlw 0x03
cpfsgt 0x12,A
bra nope3 ;h2 is at 2 but H1 is less than 5
clrf PORTD
clrf PORTJ
clrf PORTH
clrf PORTG
clrf PORTF
clrf 0x12
clrf PORTE
bra res1
nope3
clrf PORTD
clrf PORTJ
clrf PORTH
clrf PORTG
incf 0x12,F,A
movff 0x12,PORTF
bra res1
13
;
__________________________________________________________________________________
__
DELAY_1s
BSF T0CON,TMR0ON
BCF T0CON,T08BIT
BCF
T0CON,T0CS
BCF T0CON,T0SE
BCF T0CON,PSA
BSF T0CON,T0PS2
BCF T0CON,T0PS1
BSF T0CON,T0PS0
MOVLW 0X67
MOVWF TMR0H
MOVLW 0X68
MOVWF TMR0L
BCF INTCON,TMR0IF,A
WAIT
BTFSS INTCON,TMR0IF
BRA WAIT
RETURN
;_____________________________________________________________________________
ISR_PAUSE
bcf INTCON3,INT1IF
S1
btfss PORTC,0
bra S2
bra addS1
S2 BTFSS PORTC,1
bra M1
14
bra addS2
M1
btfss PORTC,2
bra M2
bra addM1
M2
btfss PORTC,3
bra H1
bra addM2
H1
btfss PORTC,4
bra H2
goto addH1
H2 btfss PORTC,5
bra resume
bra addH2
resume
BTFSS PORTB,2
bra S1
RETFIE
addS1
rcall delay.25s
incf PORTD,F,A
movlw 0x09
cpfsgt PORTD,A
BRA S1
CLRF PORTD,A
BRA S1
addS2
rcall delay.25s
15
incf PORTJ,F,A
movlw 0x05
cpfsgt PORTJ,A
BRA S1
CLRF PORTJ,A
BRA S1
addM1
rcall delay.25s
incf PORTH,F,A
movlw 0x09
cpfsgt PORTH,A
BRA S1
CLRF PORTH,A
BRA S1
addM2
rcall delay.25s
incf PORTG,F,A
movlw 0x05
cpfsgt PORTG,A
BRA S1
CLRF PORTG,A
BRA S1
addH1
rcall delay.25s
movlw 0x2
cpfseq PORTE,A
bra X
movlw 0x02
16
cpfsgt 0x12,A
bra Y
clrf PORTF,A
clrf 0x12
bra S1
X
movlw 0x08
cpfsgt 0x12,A
bra Y
clrf PORTF
clrf 0x12
bra S1
Y
incf 0x12,F,A
movff 0x12,PORTF
goto S1
addH2
rcall delay.25s
incf PORTE,F,A
movlw 0x2
cpfsgt PORTE,A
bra S1
clrf PORTE
bra S1
;
__________________________________________________________________________________
______________
17
ISR_RESET
BCF INTCON,INT0IF
clrf PORTD
clrf PORTJ
clrf PORTG
clrf PORTH
clrf PORTE
clrf PORTF
clrf 0x12,A
RETFIE
;
__________________________________________________________________________________
_______________
delay.25s
CLRF 0X18
CLRF 0X19
CLRF 0X20
MOVLW D'100'
MOVWF 0X18
LOOP4
DECFSZ 0X18,F,A
GOTO LOOP5
RETURN
LOOP5
MOVLW D'40'
MOVWF 0X19
LOOP3
DECFSZ 0X19,F,A
18
GOTO LOOP1
GOTO LOOP4
LOOP1
MOVLW D'40'
MOVWF 0X20
LOOP2
DECFSZ 0X20,F,A
GOTO LOOP2
GOTO LOOP3
RETURN
end
19