?? ac16-1.s
字號(hào):
.module ac16-1.c
.area text(rom, con, rel)
.dbfile d:\MYDOCU~1\ac16-1\ac16-1.c
.dbfunc e Delay_1ms _Delay_1ms fV
; i -> R16,R17
.even
_Delay_1ms::
.dbline -1
.dbline 24
; #include <iom16v.h>
; #include <macros.h>
; //-----------------------------------------------
; #define uchar unsigned char
; #define uint unsigned int
; //---------------引腳電平的宏定義
; #define RS_1 PORTB|=BIT(PB0)
; #define RS_0 PORTB&=~BIT(PB0)
; #define RW_1 PORTB|=BIT(PB1)
; #define RW_0 PORTB&=~BIT(PB1)
; #define EN_1 PORTB|=BIT(PB2)
; #define EN_0 PORTB&=~BIT(PB2)
; #define CS1_1 PORTB|=BIT(PB3)
; #define CS1_0 PORTB&=~BIT(PB3)
; #define CS2_1 PORTB|=BIT(PB4)
; #define CS2_0 PORTB&=~BIT(PB4)
; #define RST_1 PORTB|=BIT(PB5)
; #define RST_0 PORTB&=~BIT(PB5)
; //======================================
; #define DataPort PORTA //端口定義,雙向數(shù)據(jù)總線。
; #define xtal 8
;
; void Delay_1ms(void) //1mS延時(shí)子函數(shù)
; { uint i;
.dbline 25
; for(i=1;i<(uint)(xtal*143-2);i++)
ldi R16,1
ldi R17,0
xjmp L5
L2:
.dbline 26
L3:
.dbline 25
subi R16,255 ; offset = 1
sbci R17,255
L5:
.dbline 25
cpi R16,118
ldi R30,4
cpc R17,R30
brlo L2
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbsym r i 16 i
.dbend
.dbfunc e Delay_nms _Delay_nms fV
; i -> R20,R21
; n -> R22,R23
.even
_Delay_nms::
xcall push_gset2
movw R22,R16
.dbline -1
.dbline 30
; ;
; }
; //====================================
; void Delay_nms(uint n) //n*1mS延時(shí)子函數(shù)
; {
.dbline 31
; uint i=0;
clr R20
clr R21
xjmp L8
L7:
.dbline 33
.dbline 33
xcall _Delay_1ms
.dbline 34
subi R20,255 ; offset = 1
sbci R21,255
.dbline 35
L8:
.dbline 32
; while(i<n)
cp R20,R22
cpc R21,R23
brlo L7
.dbline -2
L6:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 i
.dbsym r n 22 i
.dbend
.dbfunc e main _main fV
; loop -> R20
.even
_main::
sbiw R28,3
.dbline -1
.dbline 54
; {Delay_1ms();
; i++;
; }
; }
; /**********函數(shù)聲明列表*************/
; void Delay_1ms(void);
; void Delay_nms(uint n);
; void wcode(uchar c,uchar sel_l,uchar sel_r);
; void wdata(uchar c,uchar sel_l,uchar sel_r);
; void set_startline(uchar i);
; void set_xy(uchar x,uchar y);
; void dison_off(uchar o);
; void reset(void);
; void m16_init(void);
; void lcd_init(void);
; void lw(uchar x, uchar y, uchar dd);
; void display_hz(uchar x, uchar y, uchar n, uchar fb);
; const uchar hz[];
; /*************主函數(shù)*************/
;
; void main(void)
; {
.dbline 56
; uchar loop;
; m16_init();
xcall _m16_init
.dbline 57
; lcd_init();
xcall _lcd_init
.dbline 58
; Delay_nms(1000);
ldi R16,1000
ldi R17,3
xcall _Delay_nms
xjmp L12
L11:
.dbline 60
; while(1)
; {
.dbline 62
; /************************************/
; for(loop=0;loop<8;loop++)
clr R20
xjmp L17
L14:
.dbline 63
.dbline 63
clr R2
std y+2,R2
std y+0,R20
clr R18
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 64
clr R2
std y+2,R2
std y+0,R20
clr R18
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 65
clr R2
std y+2,R2
std y+0,R20
clr R18
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 66
clr R2
std y+2,R2
std y+0,R20
clr R18
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 67
clr R2
std y+2,R2
std y+0,R20
clr R18
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 68
clr R2
std y+2,R2
std y+0,R20
clr R18
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 69
clr R2
std y+2,R2
std y+0,R20
clr R18
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 70
clr R2
std y+2,R2
std y+0,R20
clr R18
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 70
L15:
.dbline 62
inc R20
L17:
.dbline 62
cpi R20,8
brsh X1
xjmp L14
X1:
.dbline 72
; {display_hz(2*loop,0,loop,0);
; display_hz(2*loop,0,loop,0);
; display_hz(2*loop,0,loop,0);
; display_hz(2*loop,0,loop,0);
; display_hz(2*loop,0,loop,0);
; display_hz(2*loop,0,loop,0);
; display_hz(2*loop,0,loop,0);
; display_hz(2*loop,0,loop,0);}
; /******************************************/
; for(loop=0;loop<8;loop++)
clr R20
xjmp L21
L18:
.dbline 73
.dbline 73
clr R2
std y+2,R2
mov R24,R20
subi R24,248 ; addi 8
std y+0,R24
ldi R18,2
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 74
clr R2
std y+2,R2
mov R24,R20
subi R24,248 ; addi 8
std y+0,R24
ldi R18,2
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 75
clr R2
std y+2,R2
mov R24,R20
subi R24,248 ; addi 8
std y+0,R24
ldi R18,2
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 76
clr R2
std y+2,R2
mov R24,R20
subi R24,248 ; addi 8
std y+0,R24
ldi R18,2
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 77
clr R2
std y+2,R2
mov R24,R20
subi R24,248 ; addi 8
std y+0,R24
ldi R18,2
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 78
clr R2
std y+2,R2
mov R24,R20
subi R24,248 ; addi 8
std y+0,R24
ldi R18,2
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 79
clr R2
std y+2,R2
mov R24,R20
subi R24,248 ; addi 8
std y+0,R24
ldi R18,2
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 80
clr R2
std y+2,R2
mov R24,R20
subi R24,248 ; addi 8
std y+0,R24
ldi R18,2
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 80
L19:
.dbline 72
inc R20
L21:
.dbline 72
cpi R20,8
brsh X2
xjmp L18
X2:
.dbline 82
; {display_hz(2*loop,2,loop+8,0);
; display_hz(2*loop,2,loop+8,0);
; display_hz(2*loop,2,loop+8,0);
; display_hz(2*loop,2,loop+8,0);
; display_hz(2*loop,2,loop+8,0);
; display_hz(2*loop,2,loop+8,0);
; display_hz(2*loop,2,loop+8,0);
; display_hz(2*loop,2,loop+8,0);}
; /*************************************/
; for(loop=0;loop<8;loop++)
clr R20
xjmp L25
L22:
.dbline 83
.dbline 83
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,240 ; addi 16
std y+0,R24
ldi R18,4
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 84
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,240 ; addi 16
std y+0,R24
ldi R18,4
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 85
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,240 ; addi 16
std y+0,R24
ldi R18,4
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 86
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,240 ; addi 16
std y+0,R24
ldi R18,4
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 87
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,240 ; addi 16
std y+0,R24
ldi R18,4
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 88
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,240 ; addi 16
std y+0,R24
ldi R18,4
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 89
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,240 ; addi 16
std y+0,R24
ldi R18,4
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 90
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,240 ; addi 16
std y+0,R24
ldi R18,4
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 90
L23:
.dbline 82
inc R20
L25:
.dbline 82
cpi R20,8
brsh X3
xjmp L22
X3:
.dbline 93
; {display_hz(2*loop,4,loop+16,1);
; display_hz(2*loop,4,loop+16,1);
; display_hz(2*loop,4,loop+16,1);
; display_hz(2*loop,4,loop+16,1);
; display_hz(2*loop,4,loop+16,1);
; display_hz(2*loop,4,loop+16,1);
; display_hz(2*loop,4,loop+16,1);
; display_hz(2*loop,4,loop+16,1);}//60
;
; /**********************************/
; for(loop=0;loop<8;loop++)
clr R20
xjmp L29
L26:
.dbline 94
.dbline 94
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,232 ; addi 24
std y+0,R24
ldi R18,6
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 95
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,232 ; addi 24
std y+0,R24
ldi R18,6
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 96
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,232 ; addi 24
std y+0,R24
ldi R18,6
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 97
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,232 ; addi 24
std y+0,R24
ldi R18,6
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 98
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,232 ; addi 24
std y+0,R24
ldi R18,6
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 99
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,232 ; addi 24
std y+0,R24
ldi R18,6
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 100
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,232 ; addi 24
std y+0,R24
ldi R18,6
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 101
ldi R24,1
std y+2,R24
mov R24,R20
subi R24,232 ; addi 24
std y+0,R24
ldi R18,6
ldi R24,2
mul R24,R20
mov R16,R0
xcall _display_hz
.dbline 101
L27:
.dbline 93
inc R20
L29:
.dbline 93
cpi R20,8
brsh X4
xjmp L26
X4:
.dbline 103
ldi R16,3000
ldi R17,11
xcall _Delay_nms
.dbline 104
L12:
.dbline 59
xjmp L11
X0:
.dbline -2
L10:
adiw R28,3
.dbline 0 ; func end
ret
.dbsym r loop 20 c
.dbend
.dbfunc e m16_init _m16_init fV
.even
_m16_init::
.dbline -1
.dbline 108
; {display_hz(2*loop,6,loop+24,1);
; display_hz(2*loop,6,loop+24,1);
; display_hz(2*loop,6,loop+24,1);
; display_hz(2*loop,6,loop+24,1);
; display_hz(2*loop,6,loop+24,1);
; display_hz(2*loop,6,loop+24,1);
; display_hz(2*loop,6,loop+24,1);
; display_hz(2*loop,6,loop+24,1);}
; /*******************************/
; Delay_nms(3000);
; }
; }
; /*----------------ATMEGA16L初始化子函數(shù)。-----------------------*/
; void m16_init(void)
; {
.dbline 109
; PORTA=0x00;
clr R2
out 0x1b,R2
.dbline 110
; DDRA=0xff;
ldi R24,255
out 0x1a,R24
.dbline 111
; PORTB=0x00;
out 0x18,R2
.dbline 112
; DDRB=0xff;
out 0x17,R24
.dbline -2
L30:
.dbline 0 ; func end
ret
.dbend
.dbfunc e lcd_busy _lcd_busy fV
; val -> R16
.even
_lcd_busy::
.dbline -1
.dbline 116
; }
; /*---------------判LCM忙子函數(shù)---------------*/
; void lcd_busy(void)
; {
.dbline 118
; uchar val;
; RS_0;_NOP();
cbi 0x18,0
.dbline 118
nop
.dbline 119
; RW_1;_NOP();
sbi 0x18,1
.dbline 119
nop
.dbline 120
; DataPort=0x00;
clr R2
out 0x1b,R2
xjmp L33
L32:
.dbline 122
; while(1)
; {
.dbline 123
; EN_1;_NOP();
sbi 0x18,2
.dbline 123
nop
.dbline 124
; DDRA=0x00;
clr R2
out 0x1a,R2
.dbline 125
; val=PINA;
in R16,0x19
.dbline 126
; if(val<0x80) break;
cpi R16,128
brsh L35
.dbline 126
xjmp L34
L35:
.dbline 127
cbi 0x18,2
.dbline 127
nop
.dbline 128
L33:
.dbline 121
xjmp L32
L34:
.dbline 129
; EN_0;_NOP();
; }
; DDRA=0xff;
ldi R24,255
out 0x1a,R24
.dbline 130
; EN_0;_NOP();
cbi 0x18,2
.dbline 130
nop
.dbline -2
L31:
.dbline 0 ; func end
ret
.dbsym r val 16 c
.dbend
.dbfunc e wcode _wcode fV
; sel_r -> y+4
; sel_l -> R22
; c -> R20
.even
_wcode::
xcall push_gset2
mov R22,R18
mov R20,R16
.dbline -1
.dbline 134
; }
; /*--------------寫指令到LCM子函數(shù)---------------*/
; void wcode(uchar c,uchar sel_l,uchar sel_r)
; {
.dbline 135
; if(sel_l==1)CS1_1;
cpi R22,1
brne L38
.dbline 135
sbi 0x18,3
xjmp L39
L38:
.dbline 136
; else CS1_0;
cbi 0x18,3
L39:
.dbline 137
; _NOP();
nop
.dbline 138
; if(sel_r==1)CS2_1;
ldd R24,y+4
cpi R24,1
brne L40
.dbline 138
sbi 0x18,4
xjmp L41
L40:
.dbline 139
; else CS2_0;
cbi 0x18,4
L41:
.dbline 140
; _NOP();
nop
.dbline 141
; lcd_busy();
xcall _lcd_busy
.dbline 142
; RS_0;_NOP();
cbi 0x18,0
.dbline 142
nop
.dbline 143
; RW_0;_NOP();
cbi 0x18,1
.dbline 143
nop
.dbline 144
; DataPort=c;
out 0x1b,R20
.dbline 145
; EN_1;_NOP();
sbi 0x18,2
.dbline 145
nop
.dbline 146
; EN_0;_NOP();
cbi 0x18,2
.dbline 146
nop
.dbline -2
L37:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym l sel_r 4 c
.dbsym r sel_l 22 c
.dbsym r c 20 c
.dbend
.dbfunc e wdata _wdata fV
; sel_r -> y+4
; sel_l -> R22
; c -> R20
.even
_wdata::
xcall push_gset2
mov R22,R18
mov R20,R16
.dbline -1
.dbline 150
; }
; /*---------------寫數(shù)據(jù)到LCM子函數(shù)-------------*/
; void wdata(uchar c,uchar sel_l,uchar sel_r)
; {
.dbline 151
; if(sel_l==1)CS1_1;
cpi R22,1
brne L43
.dbline 151
sbi 0x18,3
xjmp L44
L43:
.dbline 152
; else CS1_0;
cbi 0x18,3
L44:
.dbline 153
; _NOP();
nop
.dbline 154
; if(sel_r==1)CS2_1;
ldd R24,y+4
cpi R24,1
brne L45
.dbline 154
sbi 0x18,4
xjmp L46
L45:
.dbline 155
; else CS2_0;
cbi 0x18,4
L46:
.dbline 156
; _NOP();
nop
.dbline 157
; lcd_busy();
xcall _lcd_busy
.dbline 158
; RS_1;_NOP();
sbi 0x18,0
.dbline 158
nop
.dbline 159
; RW_0;_NOP();
cbi 0x18,1
.dbline 159
nop
.dbline 160
; DataPort=c;
out 0x1b,R20
.dbline 161
; EN_1;_NOP();
sbi 0x18,2
.dbline 161
nop
.dbline 162
; EN_0;_NOP();
cbi 0x18,2
.dbline 162
nop
.dbline -2
L42:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym l sel_r 4 c
.dbsym r sel_l 22 c
.dbsym r c 20 c
.dbend
.dbfunc e lw _lw fV
; dd -> y+5
; y -> R22
; x -> R20
.even
_lw::
xcall push_gset2
mov R22,R18
mov R20,R16
sbiw R28,1
.dbline -1
.dbline 166
; }
; /*根據(jù)x、y地址定位,將數(shù)據(jù)寫入LCM左半屏或右半屏的子函數(shù)*/
; void lw(uchar x, uchar y, uchar dd)
; {
.dbline 167
; if(x>=64)
cpi R20,64
brlo L48
.dbline 168
; {set_xy(x-64,y);
.dbline 168
mov R18,R22
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -