📄 avrstudy.s
字号:
.module AVRSTUDY.C
.area data(ram, con, rel)
_AC_TABLE::
.blkb 2
.area idata
.byte 128,129
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 130,131
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 132,133
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 134,135
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 144,145
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 146,147
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 148,149
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 150,151
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 136,137
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 138,139
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 140,141
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 142,143
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 152,153
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 154,155
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 156,157
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 158,159
.area data(ram, con, rel)
.dbfile E:\AVR学习专区\AVR学习板/st7920iccavrmega8.c
.dbsym e AC_TABLE _AC_TABLE A[32:32]c
.area text(rom, con, rel)
.dbfile E:\AVR学习专区\AVR学习板/st7920iccavrmega8.c
.dbfunc e SendByte _SendByte fV
; i -> R20
; Dbyte -> R16
.even
_SendByte::
rcall push_gset1
.dbline -1
.dbline 34
; #include <iom8v.h>
; #include <macros.h>
; #include <stdio.h>
; #include "st7920iccavrmega8.c"
; #include "ds1302.c"
; #include "delay.h"
; #include "mega8_spi.c"
; #include "24cxx12864.c"
; #include "ad.c"
; #include "stepmotor.c"
; #include "串口测试.c"
;
; #pragma interrupt_handler Int0:2 //外部中断0中断函数声明
; #pragma interrupt_handler Int1:3 //外部中断1中断函数声明
; unsigned char str1[]="AVR 单片机开发板";
; unsigned char str2[]="设计制作:张国旗";
; unsigned char str3[]="→SPI 功能测试 2.I2C 功能测试 3.AD功能测试 4.步进电机测试 ";
; unsigned char str4[]="1.SPI 功能测试 →I2C 功能测试 3.AD功能测试 4.步进电机测试 ";
; unsigned char str5[]="1.SPI 功能测试 2.I2C 功能测试 →AD功能测试 4.步进电机测试 ";
; unsigned char str6[]="1.SPI 功能测试 2.I2C 功能测试 3.AD功能测试 →步进电机测试 ";
; unsigned char str7[]="2.I2C 功能测试 3.AD功能测试 4.步进电机测试 →串口通讯测试 ";
; unsigned char str8[]="3.AD功能测试 4.步进电机测试 5.串口通讯测试 →44键盘功能测试";
; unsigned char str9[]="4.步进电机测试 5.串口通讯测试 6.44键盘功能测试→返回 ";
; unsigned char str10[]="SPI 功能实验中…";
; unsigned char str11[]="步进电机实验中…";
; unsigned char str12[]=" 串口实验中… ";
; unsigned char str13[]=" 44键盘使用中…";
;
;
; uchar exit1=0,exit2=0,number1=1,enter1=0;
; //unsigned char bmp1[];//先声明一下就可以把表放在函数后面啦,呵呵
; //=========================
; // 毫秒延时函数8M晶振
; //=========================
.dbline 36
; void delay(uint ms)
; {
clr R20
rjmp L5
L2:
.dbline 37
; uint i,j;
.dbline 38
; for(i=0;i<ms;i++)
sbrs R16,7
rjmp L6
.dbline 38
sbi 0x18,6
rjmp L7
L6:
.dbline 39
; {
cbi 0x18,6
L7:
.dbline 40
sbi 0x18,7
.dbline 41
cbi 0x18,7
.dbline 42
lsl R16
.dbline 43
L3:
.dbline 36
inc R20
L5:
.dbline 36
cpi R20,8
brlo L2
.dbline -2
L1:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r Dbyte 16 c
.dbend
.dbfunc e ReceiveByte _ReceiveByte fc
; temp2 -> R16
; temp1 -> R18
; i -> R20
.even
_ReceiveByte::
rcall push_gset1
.dbline -1
.dbline 47
; for(j=0;j<1141;j++)
; {if(exit1==1){j=1141;i=ms;}}
; }
; }
;
; void Int0(void)
; {
; SREG&=0x7F;//打开全局中断
.dbline 49
; delay(100);
; exit1=1;
clr R16
clr R18
.dbline 50
; enter1=1;
clr R20
rjmp L12
L9:
.dbline 51
; SREG|=0x80;//打开全局中断
.dbline 52
;
cbi 0x17,6
.dbline 52
.dbline 53
; }
lsl R18
.dbline 54
; void Int1(void)
sbis 0x16,6
rjmp L13
.dbline 54
inc R18
L13:
.dbline 55
in R24,0x17
ori R24,194
out 0x17,R24
.dbline 55
.dbline 56
sbi 0x18,7
.dbline 57
cbi 0x18,7
.dbline 58
L10:
.dbline 50
inc R20
L12:
.dbline 50
cpi R20,8
brlo L9
.dbline 59
; {
; SREG&=0x7F;//打开全局中断
; delay(100);
;
; if(number1<7){number1++;}
clr R20
rjmp L18
L15:
.dbline 60
; else{number1=1;}
.dbline 61
;
cbi 0x17,6
.dbline 61
.dbline 62
; SREG|=0x80;//打开全局中断
lsl R16
.dbline 63
;
sbis 0x16,6
rjmp L19
.dbline 63
inc R16
L19:
.dbline 64
in R24,0x17
ori R24,194
out 0x17,R24
.dbline 64
.dbline 65
sbi 0x18,7
.dbline 66
cbi 0x18,7
.dbline 67
L16:
.dbline 59
inc R20
L18:
.dbline 59
cpi R20,8
brlo L15
.dbline 68
; }
; void Init_int()
; {
;
; MCUCR =0x00; //设置INT0、INT1为下降沿触发中断
mov R24,R16
andi R24,15
mov R16,R18
andi R16,240
add R16,R24
.dbline -2
L8:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r temp2 16 c
.dbsym r temp1 18 c
.dbsym r i 20 c
.dbend
.dbfunc e CheckBusy _CheckBusy fV
.even
_CheckBusy::
.dbline -1
.dbline 72
; DDRD&=~BIT(PD2); //配置中断管脚为输入
; PORTD|=BIT(PD2); //使能中断管脚的上拉
; DDRD&=~BIT(PD2); //配置键盘数据输入口为输入
; DDRD&=~BIT(PD3); //配置键盘数据输入口为输入
L22:
.dbline 73
; PORTD|=BIT(PD2)|BIT(PD3); //使能数据输入管脚的上拉
ldi R16,252
rcall _SendByte
L23:
.dbline 74
; SREG|=0x80;//打开全局中断
rcall _ReceiveByte
sbrc R16,7
rjmp L22
.dbline -2
L21:
.dbline 0 ; func end
ret
.dbend
.dbfunc e WriteCommand _WriteCommand fV
; Cbyte -> R20
.even
_WriteCommand::
rcall push_gset1
mov R20,R16
.dbline -1
.dbline 78
; GICR|=BIT(INT0)|BIT(INT1);//中断使能
;
; }
; void main( void )
.dbline 79
; {
rcall _CheckBusy
.dbline 80
; uchar settime[7]={0x50,0x08,0x17,0x12,0x02,0x04,0x09};//设置的秒,分,时,日,月,星期,年
ldi R16,248
rcall _SendByte
.dbline 81
; uchar gettime[7]={0x01,0x01,0x01,0x01,0x01,0x01,0x01};//保存当前时间的数组
mov R16,R20
andi R16,240
rcall _SendByte
.dbline 82
; uint i,data=0;
mov R16,R20
andi R16,#0x0F
swap R16
andi R16,240
rcall _SendByte
.dbline -2
L25:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r Cbyte 20 c
.dbend
.dbfunc e WriteData _WriteData fV
; Dbyte -> R20
.even
_WriteData::
rcall push_gset1
mov R20,R16
.dbline -1
.dbline 86
; spi_init();
; Init_int(); //中断初始化
; LcmInit(); //液晶初始化
; Delay(10);
.dbline 87
; twi_init(); //TWI初始化
rcall _CheckBusy
.dbline 88
; PORTB=0xff; //背光口开
ldi R16,250
rcall _SendByte
.dbline 89
; LCD_ON; //开液晶背光显示
mov R16,R20
andi R16,240
rcall _SendByte
.dbline 90
; DS1302_portinit(); //初始化DS1302的三根数据线
mov R16,R20
andi R16,#0x0F
swap R16
andi R16,240
rcall _SendByte
.dbline -2
L26:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r Dbyte 20 c
.dbend
.dbfunc e ReadData _ReadData fc
.even
_ReadData::
.dbline -1
.dbline 94
; //DS1302_init(); //启动振荡器,DS1302开始工作
; //DS1302_setT(settime); //设置初始时间
; while(1)
; {
.dbline 95
; PutStr(0,0,"DS1302时钟显示");
rcall _CheckBusy
.dbline 96
; PutStr(0,0,str1);
ldi R16,254
rcall _SendByte
.dbline 97
; Delay(10);
rcall _ReceiveByte
.dbline -2
L27:
.dbline 0 ; func end
ret
.dbend
.dbfunc e Delay _Delay fV
; usn -> R20
; us -> R22
; MS -> R16,R17
.even
_Delay::
rcall push_gset2
.dbline -1
.dbline 101
; PutStr(3,0,str2);
; Delay(10);
; while(exit1==0) //以下程序完成显示和设置时间
; {
rjmp L30
L29:
.dbline 104
; DS1302_getT(gettime); //获得当前时间
; Disp_time(gettime); //显示当前时间
; delay(100);
.dbline 105
; }
ldi R20,2
rjmp L33
L32:
.dbline 107
; exit1=0;
; exit2=0;
.dbline 108
; enter1=0;
ldi R22,245
rjmp L36
L35:
.dbline 109
.dbline 109
dec R22
.dbline 109
L36:
.dbline 109
tst R22
brne L35
.dbline 109
.dbline 110
dec R20
.dbline 111
L33:
.dbline 106
tst R20
brne L32
.dbline 112
subi R16,1
sbci R17,0
.dbline 113
L30:
.dbline 103
cpi R16,0
cpc R16,R17
brne L29
X0:
.dbline -2
L28:
rcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r usn 20 c
.dbsym r us 22 c
.dbsym r MS 16 i
.dbend
.dbfunc e LcmInit _LcmInit fV
.even
_LcmInit::
.dbline -1
.dbline 117
; number1=1;
; LcmInit(); //液晶初始化
; delay(10);
; while(exit2==0)
; {
; switch(number1)
; {
; case 1:{PutStr(0,0,str3);}break;
; case 2:{PutStr(0,0,str4);}break;
.dbline 118
; case 3:{PutStr(0,0,str5);}break;
ldi R16,48
rcall _WriteCommand
.dbline 119
; case 4:{PutStr(0,0,str6);}break;
ldi R16,3
rcall _WriteCommand
.dbline 120
; case 5:{PutStr(0,0,str7);}break;
ldi R16,12
rcall _WriteCommand
.dbline 121
; case 6:{PutStr(0,0,str8);}break;
ldi R16,1
rcall _WriteCommand
.dbline 122
; case 7:{PutStr(0,0,str9);}break;
ldi R16,6
rcall _WriteCommand
.dbline -2
L38:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LcmClearTXT _LcmClearTXT fV
.even
_LcmClearTXT::
.dbline -1
.dbline 126
;
; }
; delay(100);
; if(enter1==1)
.dbline 127
; {
rcall _LcmInit
.dbline -2
L39:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LcmClearBMP _LcmClearBMP fV
; i -> R20
; j -> R22
.even
_LcmClearBMP::
rcall push_gset2
.dbline -1
.dbline 131
; exit1=0;
; LcmInit(); //液晶初始化
; delay(10);
; while(exit1==0)
.dbline 133
; {
; switch(number1)
ldi R16,52
rcall _WriteCommand
.dbline 134
; {
clr R20
rjmp L44
L41:
.dbline 135
; case 1:
.dbline 136
; {
mov R16,R20
ori R16,128
rcall _WriteCommand
.dbline 137
; PutStr(1,0,str10);
ldi R16,128
rcall _WriteCommand
.dbline 138
; for(i=0;i<256;i++)
clr R22
rjmp L48
L45:
.dbline 139
clr R16
rcall _WriteData
L46:
.dbline 138
inc R22
L48:
.dbline 138
cpi R22,32
brlo L45
.dbline 140
L42:
.dbline 134
inc R20
L44:
.dbline 134
cpi R20,32
brlo L41
.dbline -2
L40:
rcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r j 22 c
.dbend
.dbfunc e PutStr _PutStr fV
; puts -> R20,R21
; col -> R22
; row -> R10
.even
_PutStr::
rcall push_gset3
mov R22,R18
mov R10,R16
ldd R20,y+6
ldd R21,y+7
.dbline -1
.dbline 145
; {
; senddat(i);
; delay(100);
; }
;
; }break;
; case 2:
.dbline 146
; {
ldi R16,48
rcall _WriteCommand
.dbline 147
; for(i=0;i<7;i++)
ldi R24,8
mul R24,R10
movw R30,R0
mov R2,R22
clr R3
add R30,R2
adc R31,R3
ldi R24,<_AC_TABLE
ldi R25,>_AC_TABLE
add R30,R24
adc R31,R25
ldd R16,z+0
rcall _WriteCommand
rjmp L51
L50:
.dbline 149
; {
; Put24c256BMP(i*1024);
.dbline 150
; delay(500);
cpi R22,8
brne L53
.dbline 151
; if(exit1==1)i=7;
.dbline 152
; }
clr R22
.dbline 153
; LcmInit(); //液晶初始化
inc R10
.dbline 154
; delay(10);
L53:
.dbline 155
; }break;
mov R24,R10
cpi R24,4
brne L55
.dbline 155
clr R10
L55:
.dbline 156
ldi R24,8
mul R24,R10
movw R30,R0
mov R2,R22
clr R3
add R30,R2
adc R31,R3
ldi R24,<_AC_TABLE
ldi R25,>_AC_TABLE
add R30,R24
adc R31,R25
ldd R16,z+0
rcall _WriteCommand
.dbline 157
movw R30,R20
ldd R16,z+0
rcall _WriteData
.dbline 158
subi R20,255 ; offset = 1
sbci R21,255
.dbline 159
movw R30,R20
ldd R16,z+0
rcall _WriteData
.dbline 160
subi R20,255 ; offset = 1
sbci R21,255
.dbline 161
inc R22
.dbline 162
L51:
.dbline 148
movw R30,R20
ldd R2,z+0
tst R2
brne L50
.dbline -2
L49:
rcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r puts 20 pc
.dbsym r col 22 c
.dbsym r row 10 c
.dbend
.dbfunc e PutBMP _PutBMP fV
; k -> R20
; x -> R22
; j -> R14
; y -> R12
; i -> R10
; puts -> y+10
.even
_PutBMP::
st -y,r17
st -y,r16
rcall push_gset5
.dbline -1
.dbline 166
; case 3:
; {
; adchange();
; delay(10);
;
; }break;
; case 4:
; {
; delay(10);
; PutStr(1,0,str11);
;
.dbline 168
; motorstar();
; }break;
ldi R22,128
.dbline 169
; case 5:
ldi R16,52
rcall _WriteCommand
.dbline 170
; {
clr R20
rjmp L61
L58:
.dbline 171
; delay(10);
.dbline 172
; PutStr(1,0,str12);
ldi R24,128
mov R12,R24
.dbline 173
;
clr R14
rjmp L65
L62:
.dbline 174
; // uart_main();
.dbline 175
; }break;
mov R16,R12
rcall _WriteCommand
.dbline 176
; case 6:
mov R16,R22
rcall _WriteCommand
.dbline 177
; {
clr R10
rjmp L69
L66:
.dbline 178
.dbline 179
ldd R30,y+10
ldd R31,y+11
ld R16,Z+
std y+11,R31
std y+10,R30
rcall _WriteData
.dbline 180
L67:
.dbline 177
inc R10
L69:
.dbline 177
mov R24,R10
cpi R24,16
brlo L66
.dbline 181
inc R12
.dbline 182
L63:
.dbline 173
inc R14
L65:
.dbline 173
mov R24,R14
cpi R24,32
brlo L62
.dbline 183
ldi R22,136
.dbline 184
L59:
.dbline 170
inc R20
L61:
.dbline 170
cpi R20,2
brlo L58
.dbline 185
; // adchange();
; PutStr(1,0,str13);
; delay(10);
;
; }break;
; case 7:{exit2=1;exit1=1;}break;
;
; }//switch
ldi R16,54
rcall _WriteCommand
.dbline -2
L57:
rcall pop_gset5
adiw R28,2
.dbline 0 ; func end
ret
.dbsym r k 20 c
.dbsym r x 22 c
.dbsym r j 14 c
.dbsym r y 12 c
.dbsym r i 10 c
.dbsym l puts 10 pc
.dbend
.dbfile E:\AVR学习专区\AVR学习板/ds1302.c
.dbfunc e Delayus _Delayus fV
; i -> R20,R21
; US -> R22,R23
.even
_Delayus::
rcall push_gset2
movw R22,R16
.dbline -1
.dbline 53
.dbline 55
ldi R16,5
ldi R17,0
movw R18,R22
rcall empy16s
movw R22,R16
lsr R23
ror R22
lsr R23
ror R22
.dbline 56
clr R20
clr R21
rjmp L74
L71:
.dbline 56
L72:
.dbline 56
subi R20,255 ; offset = 1
sbci R21,255
L74:
.dbline 56
cp R20,R22
cpc R21,R23
brlo L71
.dbline -2
L70:
rcall pop_gset2
.dbline 0 ; func end
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -