📄 main.s
字号:
.module main.c
.area text(rom, con, rel)
.dbfile E:\单片机\PROJECT\高精度三维太阳自动跟踪器\程序\传感器控制/lcm12864.h
.dbfunc e delayus _delayus fV
; us -> R16
.even
_delayus::
.dbline -1
.dbline 33
; /*****************************************
; * 基于AD转化程序设计 *
; * 功 能:AD转化 *
; * 时钟频率:内部8M *
; * 设 计:莫锦攀 *
; * 修改日期:2007年07月04日 *
; * 编译环境:ICC-AVR6.31 *
; * 实验环境:M16学习板 *
; * 使用端口:PC6,PC7,PA4~PA7,PA0 *
; *****************************************/
;
; #include <iom128v.h>
; #include <macros.h>
; #include "lcm12864.h"
; #include "delay.h"
; #define uchar unsigned char
; #define uint unsigned int
; uchar Data[5]={0,0,0,0,0};//初始值为0000,最后一个0是结束符
; void change(uint i,uchar *p) //显示处理
; {p[3]=i%10+48;//个
; p[2]=i/10%10+48;//十
; p[1]=i/100%10+48;//百
; p[0]=i/1000%10+48;//千
; }
;
; uint ADC_convert(void)//AD转换函数,读取采样获得的10位数据
; {
; uint temp1,temp2;
; temp1=(uint)ADCL;
; temp2=(uint)ADCH;
; temp2=(temp2<<8)+temp1;
; return temp2;
; }
.dbline 34
; void ADC_init(void)
xjmp L5
L2:
.dbline 35
.dbline 35
wdr
.dbline 35
L3:
.dbline 34
dec R16
L5:
.dbline 34
tst R16
brne L2
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbsym r us 16 c
.dbend
.dbfunc e delayms _delayms fV
; i -> R20,R21
; ms -> R16,R17
.even
_delayms::
xcall push_gset1
.dbline -1
.dbline 39
; { ADMUX=0x01; //选择通道PA0;外部REF+5V
; ADCSRA|=((1<<ADEN)|(1<<ADSC)|(1<<ADATE)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0));
; //使能AD;启动AD;自由转换模式;8分频
; // ADCSRA=0xc2;
; }
.dbline 42
;
; void main(void)
; {uint i,j;
xjmp L10
L7:
.dbline 43
; //uchar a;
.dbline 43
ldi R20,461
ldi R21,1
xjmp L14
L11:
.dbline 44
.dbline 44
wdr
.dbline 44
wdr
.dbline 44
L12:
.dbline 43
subi R20,1
sbci R21,0
L14:
.dbline 43
cpi R20,0
cpc R20,R21
brne L11
X0:
.dbline 45
L8:
.dbline 42
subi R16,1
sbci R17,0
L10:
.dbline 42
cpi R16,0
cpc R16,R17
brne L7
X1:
.dbline -2
L6:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 i
.dbsym r ms 16 i
.dbend
.dbfunc e data_trans _data_trans fV
; i -> R20
; data -> R16
.even
_data_trans::
xcall push_gset1
.dbline -1
.dbline 51
; PORTA = 0x00;
; DDRA = 0xFF;
; PORTB = 0x01;
; DDRB = 0xFF;
; PORTC = 0x00; //m103 output only
; DDRC = 0x00;
; PORTD = 0x00;
; DDRD = 0x0f;
.dbline 54
; PORTE = 0x00;
; DDRE = 0xF0;
; PORTF = 0x00;
ldi R20,8
xjmp L19
L16:
.dbline 55
; DDRF = 0x00;
.dbline 55
sbrs R16,7
rjmp L20
.dbline 55
sbi 0x18,6
xjmp L21
L20:
.dbline 56
; PORTG = 0x00;
cbi 0x18,6
L21:
.dbline 57
cbi 0x18,4
.dbline 58
lsl R16
.dbline 59
sbi 0x18,4
.dbline 60
L17:
.dbline 54
dec R20
L19:
.dbline 54
tst R20
brne L16
.dbline -2
L15:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r data 16 c
.dbend
.dbfunc e Send_CMD _Send_CMD fV
; temp -> R20
; com -> R22
.even
_Send_CMD::
xcall push_gset2
mov R22,R16
.dbline -1
.dbline 64
; DDRG = 0x00;
;
; LCM_init();//液晶初始化
; //DisHZ(0x89,11,"正在启动...");
; /*// ADMUX=(1<<REFS0)|(1<<REFS1);//选择第一通道ADC0,内部REF(2.56V)
; ADMUX=0x01;
; ADCSRA=0xe5;//8M32分频,125k速率,自由模式;启动AD转换器*/
;
.dbline 67
;
; ADC_init();
;
sbi 0x18,5
.dbline 68
; delay_nms(10);//延迟100ms等待系统稳定后读取数据
ldi R20,248
.dbline 69
;
mov R16,R20
xcall _data_trans
.dbline 70
;
mov R20,R22
andi R20,240
.dbline 71
; while(1)
mov R16,R20
xcall _data_trans
.dbline 72
; {
mov R20,R22
andi R20,15
.dbline 72
mov R24,R20
andi R24,#0x0F
swap R24
mov R20,R24
.dbline 73
;
mov R16,R24
xcall _data_trans
.dbline 74
; i=ADC_convert();
cbi 0x18,5
.dbline 75
; j=0;
ldi R16,70
xcall _delayus
.dbline -2
L22:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r temp 20 c
.dbsym r com 22 c
.dbend
.dbfunc e LCD_Set_DDRAM _LCD_Set_DDRAM fV
; addr -> R20
.even
_LCD_Set_DDRAM::
xcall push_gset1
mov R20,R16
.dbline -1
.dbline 79
; change(i,Data);
; DisHZXY(0,0,10,"AD测试程序");
; DisHZXY(3,1,4,Data);
; if(i>650)
.dbline 79
mov R16,R20
xcall _Send_CMD
.dbline -2
L23:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r addr 20 c
.dbend
.dbfunc e LCD_HOME _LCD_HOME fV
.even
_LCD_HOME::
.dbline -1
.dbline 82
; { DisHZXY(2,3,4,"正转");
; PORTA|=(1<<2);
; PORTC|=(1<<6);
.dbline 82
ldi R16,2
xcall _Send_CMD
.dbline -2
L24:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_CLR _LCD_CLR fV
.even
_LCD_CLR::
.dbline -1
.dbline 85
; while(j<=2000)
; {
; PORTA|=(1<<3);
.dbline 85
ldi R16,1
xcall _Send_CMD
.dbline 85
ldi R16,2
ldi R17,0
xcall _delayms
.dbline -2
L25:
.dbline 0 ; func end
ret
.dbend
.dbfunc e Send_DATA _Send_DATA fV
; temp -> R20
; data -> R22
.even
_Send_DATA::
xcall push_gset2
mov R22,R16
.dbline -1
.dbline 88
; delay_nus(17);
; PORTA&=~(1<<3);
; delay_nus(17);
.dbline 90
; j++;
; }
sbi 0x18,5
.dbline 91
; PORTC&=~(1<<6);
ldi R20,250
.dbline 92
; }
mov R16,R20
xcall _data_trans
.dbline 93
; else if(i<0xC8&&i>0x64)
mov R20,R22
andi R20,240
.dbline 94
; {DisHZXY(2,3,4,"反转");
mov R16,R20
xcall _data_trans
.dbline 95
; PORTA&=~(1<<2);
mov R20,R22
andi R20,15
.dbline 95
mov R24,R20
andi R24,#0x0F
swap R24
mov R20,R24
.dbline 96
; PORTC|=(1<<6);
mov R16,R24
xcall _data_trans
.dbline 97
; while(j<=2000)
cbi 0x18,5
.dbline 98
; {
ldi R16,40
xcall _delayus
.dbline -2
L26:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r temp 20 c
.dbsym r data 22 c
.dbend
.dbfunc e LCD_set_xy _LCD_set_xy fV
; address -> R20
; y -> R10
; x -> R22
.even
_LCD_set_xy::
xcall push_gset3
mov R10,R18
mov R22,R16
.dbline -1
.dbline 104
; PORTA|=(1<<3);
; delay_nus(17);
; PORTA&=~(1<<3);
; delay_nus(17);
; j++;
; }
.dbline 106
; PORTC&=~(1<<6);
; }
tst R10
brne L28
.dbline 106
mov R20,R22
subi R20,128 ; addi 128
xjmp L29
L28:
.dbline 107
; else
mov R24,R10
cpi R24,1
brne L30
.dbline 107
mov R20,R22
subi R20,112 ; addi 144
xjmp L31
L30:
.dbline 108
; DisHZXY(2,3,4,"停止");
mov R24,R10
cpi R24,2
brne L32
.dbline 108
mov R20,R22
subi R20,120 ; addi 136
xjmp L33
L32:
.dbline 109
; }
mov R20,R22
subi R20,104 ; addi 152
L33:
L31:
L29:
.dbline 110
;
mov R16,R20
xcall _Send_CMD
.dbline -2
L27:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r address 20 c
.dbsym r y 10 c
.dbsym r x 22 c
.dbend
.dbfunc e LCM_init _LCM_init fV
.even
_LCM_init::
.dbline -1
.dbline 116
; }
; }
; }
; }
; }
; }
.dbline 117
; }
ldi R16,50
ldi R17,0
xcall _delayms
.dbline 118
; }
ldi R16,32
xcall _Send_CMD
.dbline 119
; }
ldi R16,32
xcall _Send_CMD
.dbline 120
; }
ldi R16,12
xcall _Send_CMD
.dbline 121
; }
xcall _LCD_CLR
.dbline 122
; }
ldi R16,6
xcall _Send_CMD
.dbline -2
L34:
.dbline 0 ; func end
ret
.dbend
.area lit(rom, con, rel)
_font_wd::
.byte 0,0
.byte 0,0
.byte 0,0
.byte 4,0
.byte 10,240
.byte 5,136
.byte 3,0
.byte 2,0
.byte 2,0
.byte 3,0
.byte 1,136
.byte 0,240
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.dbsym e font_wd _font_wd A[32:32]kc
_font_bfh::
.byte 0,0
.byte 0,0
.byte 0,0
.byte 1,128
.byte 2,'L
.byte 2,'X
.byte 1,176
.byte 0,96
.byte 0,216
.byte 1,164
.byte 3,36
.byte 0,24
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.dbsym e font_bfh _font_bfh A[32:32]kc
.area text(rom, con, rel)
.dbfile E:\单片机\PROJECT\高精度三维太阳自动跟踪器\程序\传感器控制/lcm12864.h
.dbfunc e DisHZ _DisHZ fV
; i -> R20
; HZS -> R22,R23
; x -> R10,R11
; LCD_COMMAND -> R20,R21
.even
_DisHZ::
xcall push_gset3
movw R10,R18
movw R20,R16
ldd R22,y+6
ldd R23,y+7
.dbline -1
.dbline 137
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
.dbline 139
; }
; }
mov R16,R20
xcall _Send_CMD
.dbline 140
; }
clr R20
xjmp L39
L36:
.dbline 141
mov R30,R20
clr R31
add R30,R22
adc R31,R23
ldd R16,z+0
xcall _Send_DATA
L37:
.dbline 140
inc R20
L39:
.dbline 140
mov R2,R20
clr R3
cp R2,R10
cpc R3,R11
brlo L36
.dbline -2
L35:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r HZS 22 pc
.dbsym r x 10 i
.dbsym r LCD_COMMAND 20 i
.dbend
.dbfunc e DisHZXY _DisHZXY fV
; i -> R20
; HZS -> R22,R23
; z -> R10,R11
; y -> R12,R13
; x -> R20,R21
.even
_DisHZXY::
xcall push_gset4
movw R12,R18
movw R20,R16
ldd R10,y+8
ldd R11,y+9
ldd R22,y+10
ldd R23,y+11
.dbline -1
.dbline 146
; }
; }
; }
; }
; }
; }
.dbline 148
; }
; }
mov R18,R12
mov R16,R20
xcall _LCD_set_xy
.dbline 149
; }
clr R20
xjmp L44
L41:
.dbline 150
mov R30,R20
clr R31
add R30,R22
adc R31,R23
ldd R16,z+0
xcall _Send_DATA
L42:
.dbline 149
inc R20
L44:
.dbline 149
mov R2,R20
clr R3
cp R2,R10
cpc R3,R11
brlo L41
.dbline -2
L40:
xcall pop_gset4
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r HZS 22 pc
.dbsym r z 10 i
.dbsym r y 12 i
.dbsym r x 20 i
.dbend
.dbfunc e DisOneHZ _DisOneHZ fV
; Data -> R20
; LCD_COMMAND -> R22,R23
.even
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -