📄 595_1602_example.s
字号:
.module _595_1602_Example.c
.area text(rom, con, rel)
.dbfile G:\单片机\源程序\串行1602\595_1602_Example/RD_ATMega8L.h
.dbfunc e PORTDefine _PORTDefine fV
.even
_PORTDefine::
.dbline -1
.dbline 98
; /********************************************************
; * 程序说明:串行1602调试程序 *
; * 版本: v1.0 *
; * 平台: ATMega8L 8M *
; * 作者: 傻孩子 *
; * 日期: 2006年1月11日 *
; * 修改: 傻孩子 *
; * 修改日期:2006年2月19日 *
; * *
; * [说明] *
; ********************************************************/
; # include "RD_ATMega8L.h"
;
; /***********************
; * 系 统 宏 定 义 *
; ***********************/
; # pragma interrupt_handler Timer0OvfIsr:10
; /*---------------------*
; * SerialToCollateral.h *
; * 配置宏定义 *
; *---------------------*/
; # define VSCK _PC4
; # define VRCK _PC3
; # define VSI _PC5
; /*--- 定义_Use_8Bit_VitualPORT 选择单个595模式 ---*/
; # define _Use_8Bit_VitualPORT
; # include "SerialToCollateral.h"
;
; /*---------------------*
; * RD_LCD1602B.h *
; * 配置宏定义 *
; *---------------------*/
; # define LCD_RS PV4
; # define LCD_E PV5
; # define LCD_SendHalfCharLow(a) VPORT &= 0xf0;VPORT |= (a & 0x0f);refreshVirtualPORT();
; # define LCD_SendHalfCharHigh(a) VPORT &= 0xf0;VPORT |= (a >> 4);refreshVirtualPORT();
; # define SetEnable LCD_E = High;refreshVirtualPORT();
; # define SetDisable LCD_E = Low;refreshVirtualPORT();
;
; /*--- 修改FlashTimeOut来修改显示字符闪烁的频率 ---*/
; # define FlashTimeOut 800
; # define RunStringSpeed 11
; /*--- 定义_Use_LCD1602B_Serial 选择595串行连接模式(否则为直接连接模式) ---*/
; # define _Use_LCD1602B_Serial
; # include "RD_LCD1602B.h"
;
; /***********************
; * 全局变量声明区 *
; ***********************/
; unsigned int FlashGIFStringCounter = 0;
; unsigned int FlashTimeCounter = 0;
;
; /***********************
; * 系统函数声明区 *
; ***********************/
; void SystemInit(void);
; void PortInit(void);
; void Timer0Init(void);
;
; /********************************************************
; * 函数说明:端口初始化 *
; ********************************************************/
; void PortInit(void)
; {
; DDRC = 0xff;
; PORTC = 0xff;
;
; PORTDefine();
; }
;
; /********************************************************
; * 函数说明:定时器0初始化函数 *
; ********************************************************/
; void Timer0Init(void)
; {
; TCCR0 = 0x00; //stop
; TCNT0 = 0x83; //set count
; TCCR0 = 0x03; //start timer
; }
;
; /********************************************************
; * 函数说明:定时器0中断处理函数 *
; ********************************************************/
; void Timer0OvfIsr(void)
; {
; TCNT0 = 0x83;
;
; FlashGIFStringCounter ++;
; FlashTimeCounter ++;
;
; }
;
; /********************************************************
; * 函数说明:系统初始化函数 *
; ********************************************************/
; void SystemInit(void)
; {
; CLI();
.dbline 100
;
; PortInit();
ldi R24,56
ldi R25,0
sts _PORTB_BIT+1,R25
sts _PORTB_BIT,R24
.dbline 101
; Timer0Init();
ldi R24,53
sts _PORTC_BIT+1,R25
sts _PORTC_BIT,R24
.dbline 102
; LCDInit();
ldi R24,50
sts _PORTD_BIT+1,R25
sts _PORTD_BIT,R24
.dbline 104
;
; TIMSK = 0x01
ldi R24,55
sts _DDRB_BIT+1,R25
sts _DDRB_BIT,R24
.dbline 105
;
ldi R24,52
sts _DDRC_BIT+1,R25
sts _DDRC_BIT,R24
.dbline 106
; SEI();
ldi R24,49
sts _DDRD_BIT+1,R25
sts _DDRD_BIT,R24
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 18
rjmp _Timer0OvfIsr
.area text(rom, con, rel)
.dbfile G:\单片机\源程序\串行1602\595_1602_Example/RD_ATMega8L.h
.area data(ram, con, rel)
.dbfile G:\单片机\源程序\串行1602\595_1602_Example/RD_ATMega8L.h
_VPORT::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile G:\单片机\源程序\串行1602\595_1602_Example/RD_ATMega8L.h
.dbfile G:\单片机\源程序\串行1602\595_1602_Example/SerialToCollateral.h
.dbsym e VPORT _VPORT c
_VPORTBit::
.blkw 1
.area idata
.word _VPORT
.area data(ram, con, rel)
.dbfile G:\单片机\源程序\串行1602\595_1602_Example/SerialToCollateral.h
.dbstruct 0 1 VirtualPORT
.dbfield 0 BIT0 F[0:1]
.dbfield 0 BIT1 F[1:1]
.dbfield 0 BIT2 F[2:1]
.dbfield 0 BIT3 F[3:1]
.dbfield 0 BIT4 F[4:1]
.dbfield 0 BIT5 F[5:1]
.dbfield 0 BIT6 F[6:1]
.dbfield 0 BIT7 F[7:1]
.dbend
.dbsym e VPORTBit _VPORTBit pS[VirtualPORT]
_IfPortChange::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile G:\单片机\源程序\串行1602\595_1602_Example/SerialToCollateral.h
.dbsym e IfPortChange _IfPortChange c
.area text(rom, con, rel)
.dbfile G:\单片机\源程序\串行1602\595_1602_Example/SerialToCollateral.h
.dbfunc e setBIT _setBIT fc
; BIT -> R20
.even
_setBIT::
rcall push_gset1
mov R20,R16
.dbline -1
.dbline 153
; }
;
;
; void main(void)
; {
; SystemInit();
;
; while(1)
; {
; RunString("I really like this game! SWUST Roboteam ",1,1,1,16);
; Flash("Hello AVR World!",' ',1,2);
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
.dbline 154
; }
cpi R20,8
brlo L3
.dbline 155
; }
.dbline 156
; }
clr R16
rjmp L2
L3:
.dbline 159
; }
; }
; }
ldi R16,1
mov R17,R20
rcall lsl8
lds R2,_VPORT
or R2,R16
sts _VPORT,R2
.dbline 160
; }
ldi R24,1
sts _IfPortChange,R24
.dbline 161
; }
rcall _VirtualPORTProccess
.dbline 162
; }
ldi R16,1
.dbline -2
L2:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r BIT 20 c
.dbend
.dbfunc e clearBIT _clearBIT fc
; BIT -> R20
.even
_clearBIT::
rcall push_gset1
mov R20,R16
.dbline -1
.dbline 171
; }
; }
; }
; }
; }
; }
; }
; }
; }
.dbline 172
; }
cpi R20,8
brlo L6
.dbline 173
; }
.dbline 174
; }
clr R16
rjmp L5
L6:
.dbline 177
; }
; }
; }
ldi R16,1
mov R17,R20
rcall lsl8
mov R2,R16
com R2
lds R3,_VPORT
and R3,R2
sts _VPORT,R3
.dbline 178
; }
ldi R24,1
sts _IfPortChange,R24
.dbline 179
; }
rcall _VirtualPORTProccess
.dbline 180
; }
ldi R16,1
.dbline -2
L5:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r BIT 20 c
.dbend
.dbfunc e VirtualPORTProccess _VirtualPORTProccess fV
.even
_VirtualPORTProccess::
.dbline -1
.dbline 187
.dbline 188
lds R2,_IfPortChange
tst R2
breq L9
.dbline 189
.dbline 190
rcall _refreshVirtualPORT
.dbline 191
clr R2
sts _IfPortChange,R2
.dbline 192
L9:
.dbline -2
L8:
.dbline 0 ; func end
ret
.dbend
.dbfunc e refreshVirtualPORT _refreshVirtualPORT fV
; TempData -> R20
; n -> R22
.even
_refreshVirtualPORT::
rcall push_gset2
.dbline -1
.dbline 199
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
.dbline 200
; }
clr R22
.dbline 201
; }
clr R20
.dbline 203
; }
; }
lds R30,_PORTC_BIT
lds R31,_PORTC_BIT+1
ldd R24,z+0
andi R24,247
std z+0,R24
.dbline 204
; }
rjmp L15
L12:
.dbline 205
.dbline 206
mov R17,R22
lsl R17
lsl R17
lsl R17
lds R16,_VPORT
rcall lsl8
mov R20,R16
.dbline 207
rcall _sendBITS
.dbline 208
L13:
.dbline 204
inc R22
L15:
.dbline 204
cpi R22,1
brlo L12
.dbline 209
; }
; }
; }
; }
; }
lds R30,_PORTC_BIT
lds R31,_PORTC_BIT+1
ldd R24,z+0
ori R24,8
std z+0,R24
.dbline 210
; }
clr R2
sts _IfPortChange,R2
.dbline -2
L11:
rcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r TempData 20 c
.dbsym r n 22 c
.dbend
.dbfunc e sendBITS _sendBITS fV
; n -> R20
; Data -> R22
.even
_sendBITS::
rcall push_gset2
mov R22,R16
.dbline -1
.dbline 218
; }
; }
; }
; }
; }
; }
; }
; }
.dbline 219
; }
clr R20
.dbline 220
; }
rjmp L20
L17:
.dbline 221
; }
.dbline 222
; }
lds R30,_PORTC_BIT
lds R31,_PORTC_BIT+1
ldd R24,z+0
andi R24,239
std z+0,R24
.dbline 223
; }
mov R16,R22
mov R17,R20
rcall lsl8
mov R24,R16
andi R24,128
brne L21
.dbline 224
; }
.dbline 225
; }
lds R30,_PORTC_BIT
lds R31,_PORTC_BIT+1
ldd R24,z+0
andi R24,223
std z+0,R24
.dbline 226
; }
rjmp L22
L21:
.dbline 228
; }
; }
.dbline 229
; }
lds R30,_PORTC_BIT
lds R31,_PORTC_BIT+1
ldd R24,z+0
ori R24,32
std z+0,R24
.dbline 230
; }
L22:
.dbline 231
lds R30,_PORTC_BIT
lds R31,_PORTC_BIT+1
ldd R24,z+0
ori R24,16
std z+0,R24
.dbline 233
L18:
.dbline 220
inc R20
L20:
.dbline 220
cpi R20,8
brsh X0
rjmp L17
X0:
.dbline -2
L16:
rcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r n 20 c
.dbsym r Data 22 c
.dbend
.area lit(rom, con, rel)
_CHR::
.byte 48,49
.byte 50,51
.byte 52,53
.byte 54,55
.byte 56,57
.byte 'a,'b
.byte 'c,'d
.byte 'e,'f
.dbfile G:\单片机\源程序\串行1602\595_1602_Example/RD_LCD1602B.h
.dbsym e CHR _CHR A[16:16]kc
.area data(ram, con, rel)
.dbfile G:\单片机\源程序\串行1602\595_1602_Example/RD_LCD1602B.h
_LCD_Temp::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile G:\单片机\源程序\串行1602\595_1602_Example/RD_LCD1602B.h
.dbsym e LCD_Temp _LCD_Temp c
.area text(rom, con, rel)
.dbfile G:\单片机\源程序\串行1602\595_1602_Example/RD_LCD1602B.h
.dbfunc e LCDDelay _LCDDelay fV
; TimeCounter -> R20,R21
; Time -> R22,R23
.even
_LCDDelay::
rcall push_gset2
movw R22,R16
.dbline -1
.dbline 157
.dbline 158
clr R20
clr R21
.dbline 160
rjmp L27
L24:
.dbline 161
.dbline 162
ldi R16,255
ldi R17,0
rcall _LCDDelayUs
.dbline 163
L25:
.dbline 160
subi R20,255 ; offset = 1
sbci R21,255
L27:
.dbline 160
cp R20,R22
cpc R21,R23
brlo L24
.dbline -2
L23:
rcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r TimeCounter 20 i
.dbsym r Time 22 i
.dbend
.dbfunc e LCDDelayUs _LCDDelayUs fV
; TimeCounter -> R20,R21
; Time -> R16,R17
.even
_LCDDelayUs::
rcall push_gset1
.dbline -1
.dbline 171
.dbline 172
clr R20
clr R21
.dbline 173
rjmp L32
L29:
.dbline 174
.dbline 175
nop
.dbline 176
L30:
.dbline 173
subi R20,255 ; offset = 1
sbci R21,255
L32:
.dbline 173
cp R20,R16
cpc R21,R17
brlo L29
.dbline -2
L28:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r TimeCounter 20 i
.dbsym r Time 16 i
.dbend
.dbfunc e LCDInit _LCDInit fV
.even
_LCDInit::
.dbline -1
.dbline 183
.dbline 184
ldi R16,15
ldi R17,0
rcall _LCDDelay
.dbline 186
rcall _LCDWaitForReady
.dbline 187
ldi R16,40
rcall _LCDSendCommand
.dbline 189
rcall _LCDWaitForReady
.dbline 190
ldi R16,12
rcall _LCDSendCommand
.dbline 192
rcall _LCDWaitForReady
.dbline 193
ldi R16,1
rcall _LCDSendCommand
.dbline 194
ldi R16,2
ldi R17,0
rcall _LCDDelay
.dbline 195
ldi R16,6
rcall _LCDSendCommand
.dbline -2
L33:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCDSendCommand _LCDSendCommand fV
; Command -> R20
.even
_LCDSendCommand::
rcall push_gset1
mov R20,R16
.dbline -1
.dbline 278
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
.dbline 279
; }
lds R30,_VPORTBit
lds R31,_VPORTBit+1
ldd R24,z+0
andi R24,239
std z+0,R24
.dbline 279
rcall _refreshVirtualPORT
.dbline 279
.dbline 280
; }
.dbline 281
; }
lds R30,_VPORTBit
lds R31,_VPORTBit+1
ldd R24,z+0
ori R24,32
std z+0,R24
.dbline 281
rcall _refreshVirtualPORT
.dbline 281
.dbline 283
; }
; }
lds R24,_VPORT
andi R24,240
sts _VPORT,R24
.dbline 283
mov R24,R20
swap R24
andi R24,#0x0F
lds R2,_VPORT
or R2,R24
sts _VPORT,R2
.dbline 283
rcall _refreshVirtualPORT
.dbline 283
.dbline 285
; }
; }
lds R30,_VPORTBit
lds R31,_VPORTBit+1
ldd R24,z+0
andi R24,223
std z+0,R24
.dbline 285
rcall _refreshVirtualPORT
.dbline 285
.dbline 286
; }
.dbline 287
; }
.dbline 288
; }
lds R30,_VPORTBit
lds R31,_VPORTBit+1
ldd R24,z+0
ori R24,32
std z+0,R24
.dbline 288
rcall _refreshVirtualPORT
.dbline 288
.dbline 290
; }
; }
lds R24,_VPORT
andi R24,240
sts _VPORT,R24
.dbline 290
mov R24,R20
andi R24,15
lds R2,_VPORT
or R2,R24
sts _VPORT,R2
.dbline 290
rcall _refreshVirtualPORT
.dbline 290
.dbline 292
; }
; }
lds R30,_VPORTBit
lds R31,_VPORTBit+1
ldd R24,z+0
andi R24,223
std z+0,R24
.dbline 292
rcall _refreshVirtualPORT
.dbline 292
.dbline 293
; }
.dbline 294
; }
lds R30,_VPORTBit
lds R31,_VPORTBit+1
ldd R24,z+0
andi R24,239
std z+0,R24
.dbline 294
rcall _refreshVirtualPORT
.dbline 294
.dbline -2
L34:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r Command 20 c
.dbend
.dbfunc e LCDSendData _LCDSendData fV
; Data -> R20
.even
_LCDSendData::
rcall push_gset1
mov R20,R16
.dbline -1
.dbline 301
; }
; }
; }
; }
; }
; }
; }
.dbline 302
; }
lds R30,_VPORTBit
lds R31,_VPORTBit+1
ldd R24,z+0
ori R24,16
std z+0,R24
.dbline 302
rcall _refreshVirtualPORT
.dbline 302
.dbline 303
; }
.dbline 304
; }
lds R30,_VPORTBit
lds R31,_VPORTBit+1
ldd R24,z+0
ori R24,32
std z+0,R24
.dbline 304
rcall _refreshVirtualPORT
.dbline 304
.dbline 306
; }
; }
lds R24,_VPORT
andi R24,240
sts _VPORT,R24
.dbline 306
mov R24,R20
swap R24
andi R24,#0x0F
lds R2,_VPORT
or R2,R24
sts _VPORT,R2
.dbline 306
rcall _refreshVirtualPORT
.dbline 306
.dbline 308
; }
; }
lds R30,_VPORTBit
lds R31,_VPORTBit+1
ldd R24,z+0
andi R24,223
std z+0,R24
.dbline 308
rcall _refreshVirtualPORT
.dbline 308
.dbline 309
; }
.dbline 311
; }
; }
.dbline 312
; }
lds R30,_VPORTBit
lds R31,_VPORTBit+1
ldd R24,z+0
ori R24,32
std z+0,R24
.dbline 312
rcall _refreshVirtualPORT
.dbline 312
.dbline 314
; }
; }
lds R24,_VPORT
andi R24,240
sts _VPORT,R24
.dbline 314
mov R24,R20
andi R24,15
lds R2,_VPORT
or R2,R24
sts _VPORT,R2
.dbline 314
rcall _refreshVirtualPORT
.dbline 314
.dbline 316
; }
; }
lds R30,_VPORTBit
lds R31,_VPORTBit+1
ldd R24,z+0
andi R24,223
std z+0,R24
.dbline 316
rcall _refreshVirtualPORT
.dbline 316
.dbline 317
; }
.dbline 318
; }
lds R30,_VPORTBit
lds R31,_VPORTBit+1
ldd R24,z+0
andi R24,239
std z+0,R24
.dbline 318
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -