-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cau_5.asm
58 lines (47 loc) · 1.68 KB
/
Cau_5.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
;===================== Main and Interrupt Start ==================
ORG 00h ;Start from address 00h
LJMP MAIN ;Jump to Main program
ORG 03h ;External 0 interrupt start
NOP ;No code
RETI ;Return from interrupt
ORG 0Bh ;Timer 0 overflow interrupt start
NOP ;No code
RETI ;Return from interrupt
ORG 13h ;External 1 interrupt start
NOP ;No code
RETI ;Return from interrupt
ORG 1Bh ;Timer 1 overflow interrupt start
NOP ;No code
RETI ;Return from interrupt
ORG 23h ;Serial port interrupt start
NOP ;No code
RETI ;Return from interrupt
ORG 2Bh ;Timer 2 overflow interrupt start
NOP ;No code
RETI ;Return from interrupt
;====================Define Variable and Constant=================
;=================================================================
; MAIN PROGRAM
;=================================================================
ORG 50H ;Start Main program at 50H in ROM
Main:
MOV TMOD, #01H ;Choose Timer 0, mode 1 (16 bits)
;Clock of Cystal 12MHz: t = 1us
;Period of 10Hz: T = 100000us
; => Count 50000 and toggle
here:
CPL P3.0 ;Toggle Pin 3.0
LCALL Timer_Start ;Delay by timer
SJMP here ;Loop back
;=====================Define Function Program=====================
Timer_Start:
MOV TL0, #0AFH ;65535 - 50000 = 15535 = 3CAFH
MOV TH0, #03CH ;Set |TH|TL| = |3C|B0|
SETB TR0 ;start the timer 0
Wait_to_timer:
JNB TF0, Wait_to_timer ;wait until timer 0 over flag
CLR TR0 ;stop timer 0
CLR TF0 ;clear timer 0 flag
RET
;====================Define Interrupt Handler=====================
END