?? bjdj_4.s
字號:
.module bjdj_4.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:\重新整理的文件\控制類\步進電機\程序\avr/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:\重新整理的文件\控制類\步進電機\程序\avr/TWI.C
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile E:\重新整理的文件\控制類\步進電機\程序\avr/TWI.C
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile E:\重新整理的文件\控制類\步進電機\程序\avr/TWI.C
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile E:\重新整理的文件\控制類\步進電機\程序\avr/TWI.C
.dbsym e table1 _table1 A[8:8]c
.area text(rom, con, rel)
.dbfile E:\重新整理的文件\控制類\步進電機\程序\avr/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
; //電機轉一圈走27MM
; #include <iom128v.h>
; #include <iom128.h>
; #include <macros.h>
; #include "BIT.h"
; #include "zlg7290_avr.c"
;
; #define uint unsigned int
; #define uchar unsigned char
; /*********電機1控制端口************/
; #define cw1 _PA1
; #define hf1 _PA3
; #define en1 _PA5
; #define rst1 _PA7
; #define clk1 _PC6
.dbline 17
;
; /*********電機2控制端口************/
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
; #define cw2 _PA0
; #define hf2 _PA2
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
; #define en2 _PA4
; #define rst2 _PA6
; #define clk2 _PG2
;
; //uint bjl,rev,key,set=0;
; /*******************************************
; 函數名稱: delayus
; 功 能: 延時指定微秒(16M晶振)
; 參 數: us--延時的微秒數(大約,不是很精確,MS越大越準確)
.dbline 29
; 返回值 : 無
ldi R24,34
sts 112,R24
.dbline 30
; /********************************************/
clr R2
sts 113,R2
.dbline 31
; void delayus(uint us)
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
; uint i;
; us=us*5/2; //9/8是在16MHz晶振下,通過反復實驗得到的數值
; for( i=0;i<us;i++);
; }
;
; /*******************************************
; 函數名稱: delayms()
; 功 能: 16MHz晶振下延時 z ms
; 參 數: z
; 返回值 : 無
.dbline 43
; /********************************************/
ldi R24,164
sts 116,R24
L12:
.dbline 44
L13:
.dbline 44
; void delayms(uint z)
lds R2,116
sbrs R2,7
rjmp L12
.dbline 45
; {
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
; uint x,y;
; for(x=z;x>0;x--)
; for(y=2660;y>0;y--);
; }
.dbline 50
;
ldi R24,148
sts 116,R24
.dbline -2
.dbline 51
; void bjdj_init1()
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
; {
; DDRA|=BIT(1)|BIT(3)|BIT(5)|BIT(7);
; DDRC|=BIT(6);
; cw1=1; // 0:正傳 1:反轉
; en1=0; //
; rst1=0;//
; hf1=0;// 0:半步 1:整步
; }
;
; void bjdj_init2()
; {
; DDRA|=BIT(0)|BIT(2)|BIT(4)|BIT(6);
.dbline 64
; DDRG|=BIT(2);
ldi R20,1
.dbline 65
; cw2=1;//0:正傳 1:反轉
sts 115,R16
.dbline 66
; en2=0;//
ldi R24,132
sts 116,R24
L17:
.dbline 67
L18:
.dbline 67
; rst2=0;//
lds R2,116
sbrs R2,7
rjmp L17
.dbline 68
; hf2=0;//0:半步 1:整步
lds R24,113
andi R24,248
cpi R24,24
breq L20
.dbline 69
; }
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 main()
; {
; uint i,dat;
; bjdj_init1();
; bjdj_init2();
; clk1=1;
; clk2=1;
; while(1)
; {
;
.dbline 82
; clk1=1;
tst R16
breq L23
.dbline 83
; clk2=1;
ldi R24,196
sts 116,R24
xjmp L26
L23:
.dbline 85
; delayms(2);
; clk1=0;
ldi R24,132
sts 116,R24
L25:
.dbline 86
L26:
.dbline 86
; clk2=0;
lds R2,116
sbrs R2,7
rjmp L25
.dbline 87
; delayms(2);
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
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
.dbline 108
; }
; }
xcall _TWI_start
.dbline 109
; }
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
; }
; }
; }
; }
; }
; }
; }
xcall _TWI_stop
.dbline 119
; }
ldi R16,80
ldi R17,0
xcall _delay
.dbline -2
.dbline 120
; }
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
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
.dbline 140
; }
; }
mov R24,R10
clr R25
andi R24,7
andi R25,0
ldi R25,8
mov R14,R25
sub R14,R24
.dbline 141
; }
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
; }
sub R22,R14
.dbline 146
; }
mov R2,R14
clr R3
add R20,R2
adc R21,R3
.dbline 147
; }
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
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
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
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
.dbline 177
; }
; }
xcall _TWI_start
.dbline 178
; }
mov R16,R20
xcall _TWI_writeB
.dbline 179
; }
mov R16,R12
xcall _TWI_writeB
.dbline 180
; }
xcall _TWI_start
.dbline 181
; }
mov R16,R20
ori R16,1
xcall _TWI_writeB
.dbline 182
; }
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
; }
; }
; }
; }
; }
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:\重新整理的文件\控制類\步進電機\程序\avr/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:\重新整理的文件\控制類\步進電機\程序\avr/zlg7290.c
.area data(ram, con, rel)
.dbfile E:\重新整理的文件\控制類\步進電機\程序\avr/zlg7290.c
_FlagINT::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile E:\重新整理的文件\控制類\步進電機\程序\avr/zlg7290.c
.dbfile E:\重新整理的文件\控制類\步進電機\程序\avr/zlg7290_avr.c
.dbsym e FlagINT _FlagINT i
_flag::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile E:\重新整理的文件\控制類\步進電機\程序\avr/zlg7290_avr.c
.dbsym e flag _flag i
.area text(rom, con, rel)
.dbfile E:\重新整理的文件\控制類\步進電機\程序\avr/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
in R24,0x3f
st -y,R24
.dbline -1
.dbline 32
.dbline 33
ldi R24,1
ldi R25,0
sts _FlagINT+1,R25
sts _FlagINT,R24
.dbline -2
.dbline 34
L59:
ld R24,y+
out 0x3f,R24
ld R25,y+
ld R24,y+
.dbline 0 ; func end
reti
.dbend
.dbfunc e delay1 _delay1 fV
; x -> R20,R21
; y -> R22,R23
; t -> R16,R17
.even
_delay1::
xcall push_gset2
.dbline -1
.dbline 45
.dbline 47
movw R20,R16
xjmp L64
L61:
.dbline 48
ldi R22,2400
ldi R23,9
xjmp L68
L65:
.dbline 48
L66:
.dbline 48
subi R22,1
sbci R23,0
L68:
.dbline 48
cpi R22,0
cpc R22,R23
brne L65
X2:
L62:
.dbline 47
subi R20,1
sbci R21,0
L64:
.dbline 47
cpi R20,0
cpc R20,R21
brne L61
X3:
.dbline -2
.dbline 49
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -