📄 lcd1.lst
字号:
140 00003 C7C0E300 S mov.b #R, pd1 ; set reading from LCD module
141 ; (set port P10-P13 as input port)
142 ; (set port P14-P16 as output port)
143 00007 __lcd1__initial_end:
144 00007 F3 RTS ; 62.5ns*6
145
146
147 ;""SUBR COMMENT""**************************************************************
148 ; ID : ---
149 ; subroutine name : void _lcd1__wait(unsigned int t)
150 ; function : wait t*100us
151 ; input : unsigned int t: wait time (t * 50us)
152 ; output : none
153 ; subroutine used : none
154 ; stack : 0 byte
155 ; notice : the firt argument t(counter to express how many times to count
156 ; : 100us) is transferred by R1 register (argument transfer rule)
157 ; : make 50us software wait with loop wait_loop_10
158 ; : make t*50us software wait with wait_loop
159 ; : take more time to make calculate easily
160 ; :
161 ; : meaning of the value 100(1 cycle = 50ns@20MHz)
162 ; : 50000ns = 50 * (1+100*(3+7)-4)
163 ; : | | | |
164 ; : | | | +---no bifurcation
165 ; : | | +------ADJNZ
166 ; : | +--------NOP*3
167 ; : +----------------MOV
168 ; History : ---
169 ;""SUBR COMMENT END""**********************************************************
170 .section program ; same as the C program
171 .glb $_lcd1__wait ; global definition
172 00000 $_lcd1__wait:
173
174 00000 wait_loop:
175 00000 C464 S mov.b:s #100, R0L ; 50ns*1
176 00002 wait_loop_10:
177 00002 04 nop ; 50ns*1
178 00003 04 nop ; 50ns*1
179 00004 04 nop ; 50ns*1
180 00005 F8F0FB adjnz.b #-1, R0L, wait_loop_10 ; 50ns*7(when no bifurction -4)
181 00008 F9F1F6 adjnz.w #-1, R1, wait_loop ; 50ns*7(when no bifurction -4)
182
183 0000B $_lcd1__wait_end:
184 0000B F3 rts ; 50ns*6
185
186
* R8C/Tiny SERIES ASSEMBLER * SOURCE LIST Fri Oct 15 09:24:03 2004 PAGE 004
SEQ. LOC. OBJ. 0XMSDA ....*....SOURCE STATEMENT....7....*....8....*....9....*....0....*....1....*....2....*....3....*....4
187 ;""SUBR COMMENT""**************************************************************
188 ; ID : ---
189 ; subroutine name : void _lcd1__wr_nibble_creg(int command)
190 ; function : write the command to the LCD(SC1602BS*2) command register
191 ; input : int command: data to be written (only low 4 bit available)
192 ; output : none
193 ; subroutine used : none
194 ; stack : 0 byte
195 ; notice : argument command(command to be written to LCD module)
196 ; : is transferred by R1 register (argument transfer rule)
197 ; :
198 ; : control the timing as below, there is rule for time
199 ; : --------------------------+--+--+--+-------+----+-----
200 ; : TIME RS RW E I/O-DIR LCD M16C
201 ; : --------------------------+--+--+--+-------+----+-----
202 ; : def= x 0 0 RD | IN IN
203 ; : BCLR:G RS 50*3=150 0 . . . | . .
204 ; : MOV.B:S #W 50*2=100 . . . WR | . OUT
205 ; : BSET:G E 50*3=150 . . 1 . | . .
206 ; : MOV.B:G 50*2=100 . . . . | . .
207 ; : MOVLL 50*5=250 . . . . |(WR Command)
208 ; : BCLR:G E 50*3=150 . . 0 . | . .
209 ; : MOV.B:S #R 50*2=100 . . . RD | IN
210 ; History : ---
211 ;""SUBR COMMENT END""**********************************************************
212 .section program ; same section as the C program
213 .glb $_lcd1__wr_nibble_creg
214 ; global definition
215 00000 $_lcd1__wr_nibble_creg:
216 ;---- select command ----
217 00000 7E8F0E07 bclr:g p1_6_RS ; select command
218 ; (set RS port of LCD module "L")
219
220 ;---- set as writing to LCD ----
221 ;bclr:g p1_X_RW ; set LCD module as input
222 ; ; (set RW of LCD as "L":WRITE)
223 00004 C7CFE300 S mov.b:s #W, pd1 ; set CPU as output
224 ; (set P10 to P13 as output port)
225
226 ;---- write 4 bits----
227 00008 7E9F0F07 bset:g p1_7_E ; set E port of LCD module as "H"
228 0000C 7220 mov.b:g R1L, R0L ; write argument (R1) to LCD
229 0000E 7C8FE100 movll R0L, p1 ; (P1 = R1L transfer low 4 bits)
230 00012 7E8F0F07 bclr:g p1_7_E ; set E port of LCD module as "L"
231
232 ;---- set back port to initial status ----
233 00016 C7C0E300 S mov.b:s #R, pd1 ; set back P10 to P13 as input port
234 ; (set P10 to P13 as input port)
235 0001A F3 rts
236
237
238 ;""SUBR COMMENT""**************************************************************
239 ; ID : ---
240 ; subroutine name : void _lcd1__wr_nibble_dreg(int data)
241 ; function : write data to data register of LCD(SC1602BS*2)
242 ; input : int data: data to be written (only low 4 bits available)
243 ; output : none
244 ; subroutine used : none
245 ; stack : 0 byte
246 ; notice : argument data(data to be written to LCD module)
247 ; : is transferred by R1 register (argument transfer rule)
248 ; :
* R8C/Tiny SERIES ASSEMBLER * SOURCE LIST Fri Oct 15 09:24:03 2004 PAGE 005
SEQ. LOC. OBJ. 0XMSDA ....*....SOURCE STATEMENT....7....*....8....*....9....*....0....*....1....*....2....*....3....*....4
249 ; : control the timing as below, there is rule for time
250 ; : --------------------------+--+--+--+-------+----+-----
251 ; : TIME RS RW E I/O-DIR LCD M16C
252 ; : --------------------------+--+--+--+-------+----+-----
253 ; : def= x 0 0 RD | IN IN
254 ; : BSET:G RS 50*3=187.5 1 . . . | . .
255 ; : MOV.B:S #W 50*2=125.0 . . . WR | . OUT
256 ; : BSET:G E 50*3=187.5 . . 1 . | . .
257 ; : MOV.B:G 50*2=125.0 . . . . | . .
258 ; : MOVLL 50*5=312.5 . . . . |(WR Data)
259 ; : BCLR:G E 50*3=187.5 . . 0 . | . .
260 ; : MOV.B:S #R 50*2=125.0 . . . RD | IN
261 ; History : ---
262 ;""SUBR COMMENT END""**********************************************************
263 .section program ; same section as the C program
264 .glb $_lcd1__wr_nibble_dreg
265 ; global definition
266 00000 $_lcd1__wr_nibble_dreg:
267 ;---- select data ----
268 00000 7E9F0E07 bset:g p1_6_RS ; select data
269 ; (set RS port of LCD module as "H")
270
271 ;---- set as writing to LCD ----
272 ;bclr:g p1_X_RW ; set LCD module as input
273 ; ; (set RW of LCD as "L":WRITE)
274 00004 C7CFE300 S mov.b:s #W, pd1 ; set CPU as output
275 ; (set P10 to P13 as output port)
276
277 ;---- write 4 bits ----
278 00008 7E9F0F07 bset:g p1_7_E ; set E port of LCD module as "H"
279 0000C 7220 mov.b:g R1L, R0L ; write argument (R1) to LCD
280 0000E 7C8FE100 movll R0L, p1 ; 仾(P1 = R1L transfer low 4 bits)
281 00012 7E8F0F07 bclr:g p1_7_E ; set E port of LCD module as "L"
282
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -