📄 zlg7290_avr.s
字号:
.module zlg7290_avr.c
.area data(ram, con, rel)
_table::
.blkb 2
.area idata
.byte 1,2
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 4,8
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 16,32
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 64,128
.area data(ram, con, rel)
.dbfile E:\PQ-1A\我的AVR\zlg7290/TWI.C
.dbsym e table _table A[8:8]c
_table1::
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile E:\PQ-1A\我的AVR\zlg7290/TWI.C
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile E:\PQ-1A\我的AVR\zlg7290/TWI.C
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile E:\PQ-1A\我的AVR\zlg7290/TWI.C
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile E:\PQ-1A\我的AVR\zlg7290/TWI.C
.dbsym e table1 _table1 A[8:8]c
.area text(rom, con, rel)
.dbfile E:\PQ-1A\我的AVR\zlg7290/TWI.C
.dbfunc e delay _delay fV
; x -> R20,R21
; y -> R22,R23
; z -> R16,R17
.even
_delay::
xcall push_gset2
.dbline -1
.dbline 15
; #include <iom128v.h>
; #include <iom128.h>
; #include <macros.h>
; //#include <stdio.h> //标准输入输出头文件
; #include "zlg7290.c"
;
; #define uchar unsigned char
; #define uint unsigned int
; #pragma interrupt_handler extint0:9
; //#pragma interrupt_handler miao:15
;
; uint FlagINT = 0,flag=0;
;
; /*
; 函数:interrupt_init()
.dbline 17
; 功能:ZLG7290键盘中断服务初始化程序
; */
movw R20,R16
xjmp L5
L2:
.dbline 18
ldi R22,1100
ldi R23,4
xjmp L9
L6:
.dbline 18
L7:
.dbline 18
subi R22,1
sbci R23,0
L9:
.dbline 18
cpi R22,0
cpc R22,R23
brne L6
X0:
L3:
.dbline 17
subi R20,1
sbci R21,0
L5:
.dbline 17
cpi R20,0
cpc R20,R21
brne L2
X1:
.dbline -2
.dbline 19
; void interrupt_init(void)
; {
L1:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r x 20 i
.dbsym r y 22 i
.dbsym r z 16 i
.dbend
.dbfunc e TWI_init _TWI_init fV
.even
_TWI_init::
.dbline -1
.dbline 28
; SEI(); //使能全局中断
; EIMSK=0x80; //使能外部中断7
; EICRB=0x80; //外部中断7采用下降沿触发
; DDRE&=~0x80; //配置中断管脚为输入
; PORTE|=BIT(PE7); //使能中断管脚的上拉
; }
; /*
; 函数:extint0()
; 功能:ZLG7290键盘中断服务程序
.dbline 29
; 说明:中断触发方式选择负边沿触发,因此不必等待中断请求信号恢复为高电平
ldi R24,34
sts 112,R24
.dbline 30
; */
clr R2
sts 113,R2
.dbline 31
; void extint0(void)
ldi R24,68
sts 116,R24
.dbline -2
.dbline 32
; {
L10:
.dbline 0 ; func end
ret
.dbend
.dbfunc e TWI_start _TWI_start fc
.even
_TWI_start::
.dbline -1
.dbline 42
; FlagINT = 1;
; }
; /*
; /void miao()
; {
; flag=1;
; }
;
;
; 函数:delay1()
.dbline 43
; 功能:延时10ms~655.36s
ldi R24,164
sts 116,R24
L12:
.dbline 44
L13:
.dbline 44
; 参数:
lds R2,116
sbrs R2,7
rjmp L12
.dbline 45
; t>0时,延时(t*0.01)s
ldi R16,1
.dbline -2
L11:
.dbline 0 ; func end
ret
.dbend
.dbfunc e TWI_stop _TWI_stop fV
.even
_TWI_stop::
.dbline -1
.dbline 49
; t=0时,延时655.36s
; 说明:
; 晶振采用8.31MHz
; */
.dbline 50
; void delay1(uint t)
ldi R24,148
sts 116,R24
.dbline -2
.dbline 51
; {
L15:
.dbline 0 ; func end
ret
.dbend
.dbfunc e TWI_writeB _TWI_writeB fc
; ack -> R20
; c -> R16
.even
_TWI_writeB::
xcall push_gset1
.dbline -1
.dbline 63
; uint x,y;
; for(x=t;x>0;x--)
; for(y=110;y>0;y--);
; }
;
; /*
; 函数:SystemInit()
; 功能:系统初始化
; */
; void SystemInit()
; {
; TWI_init();
.dbline 64
; interrupt_init();
ldi R20,1
.dbline 65
; delay1(30); //等待ZLG7290复位完毕
sts 115,R16
.dbline 66
; }
ldi R24,132
sts 116,R24
L17:
.dbline 67
L18:
.dbline 67
;
lds R2,116
sbrs R2,7
rjmp L17
.dbline 68
; /*
lds R24,113
andi R24,248
cpi R24,24
breq L20
.dbline 69
; 函数:ClearAll()
clr R20
L20:
.dbline 70
; 功能:清除所有显示
mov R16,R20
.dbline -2
L16:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r ack 20 c
.dbsym r c 16 c
.dbend
.dbfunc e TWI_readB _TWI_readB fc
; ack -> R16
.even
_TWI_readB::
.dbline -1
.dbline 81
; */
; void ClearAll()
; {
; uchar x;
; for ( x=0; x<8; x++ )
; {
; ZLG7290_Download(x,0,0,31);
; }
; }
;
; /*
.dbline 82
; 函数:Test_DispBuf()
tst R16
breq L23
.dbline 83
; 功能:测试直接写显存
ldi R24,196
sts 116,R24
xjmp L26
L23:
.dbline 85
; */
; void Test_DispBuf()
ldi R24,132
sts 116,R24
L25:
.dbline 86
L26:
.dbline 86
; {
lds R2,116
sbrs R2,7
rjmp L25
.dbline 87
; uchar DispDat[16] =
lds R16,115
.dbline -2
L22:
.dbline 0 ; func end
ret
.dbsym r ack 16 c
.dbend
.dbfunc e TWI_page_write _TWI_page_write fc
; i -> R20
; arr -> R22,R23
; n -> R10
; addr -> R20
; devadd -> R12
.even
_TWI_page_write::
xcall push_gset4
mov R20,R18
mov R12,R16
ldd R10,y+8
ldd R22,y+10
ldd R23,y+11
.dbline -1
.dbline 106
; {//字母AbCdEFgHiJkLoPqr的字形数据
; 0xEE,0x3E,0x9C,0x7A,0x9E,0x8E,0xF6,0x6E,
; 0x20,0x70,0x0E,0x1C,0x3A,0xCE,0xE6,0x0A
; };
; uchar n;
; uchar x;
; uchar reg;
; uchar dat;
; for ( n=0; n<16; n++ )
; {
; for ( x=0; x<8; x++ )
; {
; reg = ZLG7290_DpRam + x;
; dat = DispDat[n];
; ZLG7290_WriteReg(reg,dat);
; }
; delay1(50);
; }
; }
.dbline 108
;
; /*
xcall _TWI_start
.dbline 109
; 函数:Test_Download()
mov R16,R12
xcall _TWI_writeB
.dbline 110
; 功能:测试下载数据功能
mov R16,R20
xcall _TWI_writeB
.dbline 111
; */
ldi R20,1
xjmp L32
L29:
.dbline 112
.dbline 115
movw R30,R22
ldd R16,z+0
xcall _TWI_writeB
.dbline 116
subi R22,255 ; offset = 1
sbci R23,255
.dbline 117
L30:
.dbline 111
inc R20
L32:
.dbline 111
cp R10,R20
brsh L29
.dbline 118
; void Test_Download()
; {
; uchar x;
; uchar dp;
; uchar f;
; uchar dat;
; //点亮所有数码管
xcall _TWI_stop
.dbline 119
; dp = 1;
ldi R16,80
ldi R17,0
xcall _delay
.dbline -2
.dbline 120
; f= 0;
L28:
xcall pop_gset4
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r arr 22 pc
.dbsym r n 10 c
.dbsym r addr 20 c
.dbsym r devadd 12 c
.dbend
.dbfunc e TWI_write _TWI_write fc
; n_tmp -> R14
; arr -> R20,R21
; n -> R22
; addr -> R10
; devadd -> R12
.even
_TWI_write::
xcall push_gset5
mov R10,R18
mov R12,R16
sbiw R28,4
ldd R22,y+14
ldd R20,y+16
ldd R21,y+17
.dbline -1
.dbline 138
; dat = 8;
; for ( x=0; x<8; x++ )
; {
; ZLG7290_Download(x,dp,f,dat);
; }
; delay1(100);
; //依次显示所有字型
; dp = 0;
; f = 0;
; for ( dat=0; dat<32; dat++ )
; {
; for ( x=0; x<8; x++ )
; {
; ZLG7290_Download(x,dp,f,dat);
; }
; delay1(50);
; }
; }
.dbline 140
;
; /*
mov R24,R10
clr R25
andi R24,7
andi R25,0
ldi R25,8
mov R14,R25
sub R14,R24
.dbline 141
; 函数:Test_ScanNum()
cp R14,R22
brsh L37
tst R14
breq L37
.dbline 142
; 功能:测试不同扫描位数
.dbline 143
; 说明:扫描位数越少,数码管就越亮
std y+2,R20
std y+3,R21
std y+0,R14
mov R18,R10
mov R16,R12
xcall _TWI_page_write
.dbline 144
; */
add R10,R14
.dbline 145
; void Test_ScanNum()
sub R22,R14
.dbline 146
; {
mov R2,R14
clr R3
add R20,R2
adc R21,R3
.dbline 147
; uchar x;
xjmp L37
L36:
.dbline 149
.dbline 150
std y+2,R20
std y+3,R21
ldi R24,8
std y+0,R24
mov R18,R10
mov R16,R12
xcall _TWI_page_write
.dbline 151
mov R24,R10
subi R24,248 ; addi 8
mov R10,R24
.dbline 152
subi R22,8
.dbline 153
subi R20,248 ; offset = 8
sbci R21,255
.dbline 154
L37:
.dbline 148
cpi R22,8
brsh L36
.dbline 155
tst R22
breq L39
.dbline 156
std y+2,R20
std y+3,R21
std y+0,R22
mov R18,R10
mov R16,R12
xcall _TWI_page_write
L39:
.dbline -2
.dbline 157
; for ( x=0; x<8; x++ )
; {
; ZLG7290_Download(x,1,0,8);
; }
; delay1(100);
; for ( x=0; x<8; x++ )
; {
; ZLG7290_WriteReg(ZLG7290_ScanNum,x);
; delay(100);
; }
L33:
adiw R28,4
xcall pop_gset5
.dbline 0 ; func end
ret
.dbsym r n_tmp 14 c
.dbsym r arr 20 pc
.dbsym r n 22 c
.dbsym r addr 10 c
.dbsym r devadd 12 c
.dbend
.dbfunc e TWI_read _TWI_read fc
; i -> R20
; arr -> R22,R23
; n -> R10
; addr -> R12
; devadd -> R20
.even
_TWI_read::
xcall push_gset4
mov R12,R18
mov R20,R16
ldd R10,y+8
ldd R22,y+10
ldd R23,y+11
.dbline -1
.dbline 175
; }
;
; /*
; 函数:Test_Flash()
; 功能:测试闪烁功能
; */
; void Test_Flash()
; {
; uchar dat = 0x01;
; uchar x;
; //显示01234567
; for ( x=0; x<8; x++ )
; {
; ZLG7290_Download(x,0,0,x);
; }
; //设置闪烁控制寄存器
; ZLG7290_WriteReg(ZLG7290_FlashOnOff,0x11);
; //闪烁演示
.dbline 177
; for ( x=0; x<8; x++ )
; {
xcall _TWI_start
.dbline 178
; ZLG7290_Flash(dat);
mov R16,R20
xcall _TWI_writeB
.dbline 179
; dat <<= 1;
mov R16,R12
xcall _TWI_writeB
.dbline 180
; delay1(300);
xcall _TWI_start
.dbline 181
; }
mov R16,R20
ori R16,1
xcall _TWI_writeB
.dbline 182
; //数码管的8个位一起闪烁
ldi R20,1
xjmp L45
L42:
.dbline 183
.dbline 184
ldi R16,1
xcall _TWI_readB
movw R30,R22
std z+0,R16
.dbline 185
subi R22,255 ; offset = 1
sbci R23,255
.dbline 186
L43:
.dbline 182
inc R20
L45:
.dbline 182
mov R24,R10
subi R24,1
cp R24,R20
brsh L42
.dbline 187
; ZLG7290_Flash(0xFF);
; delay1(350);
; //停止闪烁
; ZLG7290_Flash(0x00);
; delay1(50);
clr R16
xcall _TWI_readB
movw R30,R22
std z+0,R16
.dbline 188
; }
xcall _TWI_stop
.dbline -2
.dbline 189
;
L41:
xcall pop_gset4
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r arr 22 pc
.dbsym r n 10 c
.dbsym r addr 12 c
.dbsym r devadd 20 c
.dbend
.dbfile E:\PQ-1A\我的AVR\zlg7290/zlg7290.c
.dbfunc e ZLG7290_WriteReg _ZLG7290_WriteReg fV
; dat -> y+6
; RegAddr -> R20
.even
_ZLG7290_WriteReg::
st -y,r19
st -y,r18
xcall push_gset1
mov R20,R16
sbiw R28,4
.dbline -1
.dbline 23
.dbline 24
movw R24,R28
adiw R24,6
std y+2,R24
std y+3,R25
ldi R24,1
std y+0,R24
mov R18,R20
ldi R16,112
xcall _TWI_write
.dbline -2
.dbline 25
L46:
adiw R28,4
xcall pop_gset1
adiw R28,2
.dbline 0 ; func end
ret
.dbsym l dat 6 I
.dbsym l dat 6 c
.dbsym r RegAddr 20 c
.dbend
.dbfunc e ZLG7290_ReadReg _ZLG7290_ReadReg fV
; dat -> R22,R23
; RegAddr -> R20
.even
_ZLG7290_ReadReg::
xcall push_gset2
movw R22,R18
mov R20,R16
sbiw R28,4
.dbline -1
.dbline 38
.dbline 39
std y+2,R22
std y+3,R23
ldi R24,1
std y+0,R24
mov R18,R20
ldi R16,112
xcall _TWI_read
.dbline -2
.dbline 40
L47:
adiw R28,4
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r dat 22 pc
.dbsym r RegAddr 20 c
.dbend
.dbfunc e ZLG7290_cmd _ZLG7290_cmd fV
; buf -> y+4
; cmd1 -> R20
; cmd0 -> R22
.even
_ZLG7290_cmd::
xcall push_gset2
mov R20,R18
mov R22,R16
sbiw R28,6
.dbline -1
.dbline 53
.dbline 55
std y+4,R22
.dbline 56
std y+5,R20
.dbline 57
movw R24,R28
adiw R24,4
std y+2,R24
std y+3,R25
ldi R24,2
std y+0,R24
ldi R18,7
ldi R16,112
xcall _TWI_write
.dbline -2
.dbline 58
L48:
adiw R28,6
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym l buf 4 A[2:2]c
.dbsym r cmd1 20 c
.dbsym r cmd0 22 c
.dbend
.dbfunc e ZLG7290_SegOnOff _ZLG7290_SegOnOff fV
; cmd -> R20
; b -> R22
; seg -> R20
.even
_ZLG7290_SegOnOff::
xcall push_gset2
mov R22,R18
mov R20,R16
.dbline -1
.dbline 73
.dbline 75
andi R20,63
.dbline 76
tst R22
breq L51
.dbline 76
ori R20,128
L51:
.dbline 77
mov R18,R20
ldi R16,1
xcall _ZLG7290_cmd
.dbline -2
.dbline 78
L50:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r cmd 20 c
.dbsym r b 22 c
.dbsym r seg 20 c
.dbend
.dbfunc e ZLG7290_Download _ZLG7290_Download fV
; cmd1 -> R22
; cmd0 -> R20
; dat -> y+8
; f -> y+6
; dp -> R10
; addr -> R20
.even
_ZLG7290_Download::
xcall push_gset3
mov R10,R18
mov R20,R16
.dbline -1
.dbline 94
.dbline 97
andi R20,15
.dbline 98
ori R20,96
.dbline 99
ldd R22,y+8
andi R22,31
.dbline 100
mov R24,R10
cpi R24,1
brne L54
.dbline 100
ori R22,128
L54:
.dbline 101
ldd R24,y+6
cpi R24,1
brne L56
.dbline 101
ori R22,64
L56:
.dbline 102
mov R18,R22
mov R16,R20
xcall _ZLG7290_cmd
.dbline -2
.dbline 103
L53:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r cmd1 22 c
.dbsym r cmd0 20 c
.dbsym l dat 8 c
.dbsym l f 6 c
.dbsym r dp 10 c
.dbsym r addr 20 c
.dbend
.area vector(rom, abs)
.org 32
jmp _extint0
.area text(rom, con, rel)
.dbfile E:\PQ-1A\我的AVR\zlg7290/zlg7290.c
.area data(ram, con, rel)
.dbfile E:\PQ-1A\我的AVR\zlg7290/zlg7290.c
_FlagINT::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile E:\PQ-1A\我的AVR\zlg7290/zlg7290.c
.dbfile E:\PQ-1A\我的AVR\zlg7290\zlg7290_avr.c
.dbsym e FlagINT _FlagINT i
_flag::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile E:\PQ-1A\我的AVR\zlg7290\zlg7290_avr.c
.dbsym e flag _flag i
.area text(rom, con, rel)
.dbfile E:\PQ-1A\我的AVR\zlg7290\zlg7290_avr.c
.dbfunc e interrupt_init _interrupt_init fV
.even
_interrupt_init::
.dbline -1
.dbline 19
.dbline 20
sei
.dbline 21
ldi R24,128
out 0x39,R24
.dbline 22
out 0x3a,R24
.dbline 23
cbi 0x2,7
.dbline 24
sbi 0x3,7
.dbline -2
.dbline 25
L58:
.dbline 0 ; func end
ret
.dbend
.dbfunc e extint0 _extint0 fV
.even
_extint0::
st -y,R24
st -y,R25
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -