📄 initialize.lst
字号:
1 000000 ;**********************************************
2 000000 ;Name :RAMInitial
3 000000 ;Function:clr bank0~bank1
4 000000 ;Input :
5 000000 ;Output :
6 000000 ;Register Used:
7 000000 ;***********************************************
8 000000 RAMInitial:
9 000000 clr y
10 000000 mov a,#7fh
11 000000 b0mov z,a
12 000000 Clrbank0:
13 000000 clr @YZ ;Clear @YZ content
14 000000 decms Z ;z = z - 1 , skip next if z=0
15 000000 jmp Clrbank0
16 000000 clr @YZ ;Clear address 0x00
17 000000 ;-----
18 000000 ;preset some constant
19 000000
20 000000 mov_ timer10ms,#20 ;10ms
21 000000 mov_ timer1s,#100 ;1s
22 000000 mov_ timer1m,#60 ;1m
23 000000 mov_ timer1h,#60 ;1h
24 000000 mov_ displaytimer,#2
25 000000 mov_ combuf,#11111111b ;set all com high level
26 000000 mov_ pwmpulsebuf,#20 ;set initialize pwm pusle=20/64
27 000000 mov a,#50 ;set led frequent=0.5s
28 000000 mov frequentbuf3,a
29 000000 mov ledfrequent,a
30 000000 mov frequentbuf2,a
31 000000 mov loadfrequent,a
32 000000 ret
33 000000 ;**********************************************
34 000000 ;Name :PortInitial
35 000000 ;Function:
36 000000 ;Input :
37 000000 ;Output :
38 000000 ;Register Used:
39 000000 ;***********************************************
40 000000 PortInitial:
41 000000
42 000000 mov a,#0ffh
43 000000 mov p2m,a ;set p2 is output port
44 000000 mov p2,a ;set all p2 pin high level
45 000000
46 000000 mov a,#11110000b ;set p4.7~p4.4 is output,others is input
47 000000 mov p4m,a
48 000000 mov a,#11110000b
49 000000 mov p4,a
50 000000 clr p4ur
51 000000
52 000000 mov a,#11111111b
53 000000 mov p5m,a ;set p5 is output except p5.1
54 000000 mov a,#11001011b
55 000000 mov p5,a
56 000000
57 000000 ret
58 000000
59 000000 ;**********************************************
60 000000 ;Name :SysInitial
61 000000 ;Function:
62 000000 ;Input :
63 000000 ;Output :
64 000000 ;Register Used:
65 000000 ;***********************************************
66 000000 SysInitial:
67 000000 ;-----
68 000000 clr t0m ;ftc1=fcpu
69 000000 /*
70 000000 bclr ftc0ien ;dis t0 int
71 000000 bclr ftc0enb ;stop t0 count
72 000000 mov A,#00100100B ;//f0=fcpu/64
73 000000 b0mov Tc0M,A
74 000000 mov A,#100 ;//10ms constant for f0=1mips/64
75 000000 b0mov Tc0C,A
76 000000 b0mov Tc0r,a
77 000000 b0bset FTc0ENB ; Enable TIMER0
78 000000 bset FTc0IEN ; Enable T0 interrupt
79 000000 bclr ftc0irq ; CLEAR TIMER0 INTERRUPT FLAG
80 000000 */
81 000000 bclr ftc0ien ;dis t0 int
82 000000 bclr ftc0enb ;stop t0 count
83 000000 mov A,#01100100B ;//f0=fcpu/4
84 000000 ;// mov A,#01010100B ;//f0=fcpu/4
85 000000 b0mov Tc0M,A
86 000000 mov A,#131 ;//0.5ms constant for f0=1mips/64
87 000000 ;// mov A,#194 ;0.25ms
88 000000 b0mov Tc0C,A
89 000000 b0mov Tc0r,a
90 000000 b0bset FTc0ENB ; Enable TIMER0
91 000000 bset FTc0IEN ; Enable T0 interrupt
92 000000 bclr ftc0irq ; CLEAR TIMER0 INTERRUPT FLAG
93 000000 ;----
94 000000 ;初始化pwm
95 000000 bclr ftc1ien ;dis t1 int
96 000000 clr tc1c
97 000000 ;// mov a,#01100100b
98 000000 mov a,#01100010b
99 000000 b0mov tc1m,a ;set pwm=32 duty fpwm=62.5k
100 000000 bset fpwm1out
101 000000 bset ftc1out
102 000000 ;// bclr fpwm1out
103 000000 bset ftc1enb ;stop t1 count
104 000000 mov_ tc1r,#40
105 000000 jmp $
106 000000 ;----
107 000000 clr ADM
108 000000 b0bset FADENB ;enable adc
109 000000 mov_ ADR,#01010000b ;select 12 bit ADC,Fcpu/2=128us
110 000000 ;// b0bset fadenb ;enable ad
111 000000 ;// call delay100us ;stable ad circuit
112 000000 ;----
113 000000 bclr fp00irq
114 000000 mov_ pedge,#10h ;p00 falling edge
115 000000 bset fp00ien
116 000000
117 000000 bclr fp01irq ;p01 falling edge
118 000000 ;// bset fp01ien
119 000000 ;----
120 000000 bset poweronflag ;通电标志
121 000000 b0bset FGIE ;//enable Interrupt gain
122 000000 ret
123 000000
124 000000 ;**********************************************
125 000000 ;Name :Pdelay
126 000000 ;Function:
127 000000 ;Input :
128 000000 ;Output :
129 000000 ;Register Used:
130 000000 ;***********************************************
131 000000 Pdelay:
132 000000 mov a,#0ffh
133 000000 mov var1,a
134 000000 loop10:
135 000000 mov a,#0ffh
136 000000 mov var2,a
137 000000 loop11:
138 000000 decms var2
139 000000 jmp loop11 ;power on delay
140 000000 decms var1
141 000000 jmp loop10
142 000000 ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -