?? 寶貝機(jī)器人.s
字號:
.module _寶貝機(jī)器人.c
.area data(ram, con, rel)
_turn_state0::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\eda\桌面\寶貝機(jī)器人.c
.dbsym e turn_state0 _turn_state0 c
_turn_state1::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\eda\桌面\寶貝機(jī)器人.c
.dbsym e turn_state1 _turn_state1 c
_minute::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\eda\桌面\寶貝機(jī)器人.c
.dbsym e minute _minute c
_number::
.blkb 2
.area idata
.byte 136,187
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\eda\桌面\寶貝機(jī)器人.c
.blkb 2
.area idata
.byte 193,145
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\eda\桌面\寶貝機(jī)器人.c
.blkb 2
.area idata
.byte 178,148
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\eda\桌面\寶貝機(jī)器人.c
.blkb 2
.area idata
.byte 132,185
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\eda\桌面\寶貝機(jī)器人.c
.blkb 2
.area idata
.byte 128,144
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\eda\桌面\寶貝機(jī)器人.c
.blkb 2
.area idata
.byte 0,255
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\eda\桌面\寶貝機(jī)器人.c
.dbsym e number _number A[12:12]c
.area text(rom, con, rel)
.dbfile C:\DOCUME~1\eda\桌面\寶貝機(jī)器人.c
.dbfunc e delay_us _delay_us fV
; time -> R16,R17
.even
_delay_us::
.dbline -1
.dbline 13
; //電機(jī)在第一次使用之前,都得先調(diào)零,即調(diào)用stop()子程序旋轉(zhuǎn)調(diào)整螺絲直到其轉(zhuǎn)速為零
; //PD6\7分別控制左、右電機(jī)為白線。紅黑先分別接電源和地
; //電機(jī)轉(zhuǎn)速通過脈沖信號控制,
; //1.5ms停轉(zhuǎn)、1.3ms正轉(zhuǎn)、1.7ms為反轉(zhuǎn)(都為高電平)中間插入20ms的低電平
; //PC3,4控制顯示,PC3傳送數(shù)據(jù),PC4為時鐘信號線
; // PC0 1分別為探測光源的左 右端口,
; //創(chuàng)建時間:2005年7月28日19:44~8。10
; #include "iom16v.h"
; #include "macros.h"
; unsigned char turn_state0=0,turn_state1=0,sec,second,mini,minute=0,minisecond,number[12]={0x88,0xbb,0xc1,0x91,0xb2,0x94,0x84,0xb9,0x80,0x90,0x00,0xff};
; unsigned int left,right,zhong,interval;
; void delay_us(unsigned int time)
; {//微秒級延時程序
L2:
.dbline 15
; do
; {
.dbline 16
; time--;
subi R16,1
sbci R17,0
.dbline 17
; }
L3:
.dbline 18
; while (time>1);
ldi R24,1
ldi R25,0
cp R24,R16
cpc R25,R17
brlo L2
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbsym r time 16 i
.dbend
.dbfunc e delay_ms _delay_ms fV
; time -> R20,R21
.even
_delay_ms::
xcall push_gset1
movw R20,R16
.dbline -1
.dbline 22
; }
;
; void delay_ms(unsigned int time)
; {//毫秒級延時程序
xjmp L7
L6:
.dbline 24
.dbline 25
ldi R16,1000
ldi R17,3
xcall _delay_us
.dbline 26
subi R20,1
sbci R21,0
.dbline 27
L7:
.dbline 23
; while(time!=0)
cpi R20,0
cpc R20,R21
brne L6
X0:
.dbline -2
L5:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r time 20 i
.dbend
.dbfunc e delay_20ms _delay_20ms fV
; time -> R20
.even
_delay_20ms::
xcall push_gset1
.dbline -1
.dbline 33
; {
; delay_us(1000);
; time--;
; }
; }
;
;
; /////////////////小車運(yùn)動////////////////////////////////////////
; void delay_20ms()//延時20ms,用于插入低電平
; {//毫秒級延時程序
.dbline 34
; unsigned char time=20;
ldi R20,20
xjmp L11
L10:
.dbline 36
.dbline 37
ldi R16,126
ldi R17,0
xcall _delay_us
.dbline 38
dec R20
.dbline 39
L11:
.dbline 35
; while(time!=0)
tst R20
brne L10
.dbline -2
L9:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r time 20 c
.dbend
.dbfunc e delay_stop _delay_stop fV
; time -> R20
.even
_delay_stop::
xcall push_gset1
.dbline -1
.dbline 42
; {
; delay_us(126);
; time--;
; }
; }
; void delay_stop()//延時1.5m,用于停轉(zhuǎn)
; {//毫秒級延時程序
.dbline 43
; unsigned char time=1;
ldi R20,1
xjmp L15
L14:
.dbline 45
.dbline 46
ldi R16,183
ldi R17,0
xcall _delay_us
.dbline 47
dec R20
.dbline 48
L15:
.dbline 44
; while(time!=0)
tst R20
brne L14
.dbline -2
L13:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r time 20 c
.dbend
.dbfunc e delay_conver _delay_conver fV
; time -> R20
.even
_delay_conver::
xcall push_gset1
.dbline -1
.dbline 51
; {
; delay_us(183);
; time--;
; }
; }
; void delay_conver()//延時0.4ms,用于正反轉(zhuǎn)變換
; {//毫秒級延時程序
.dbline 52
; unsigned char time=1;
ldi R20,1
xjmp L19
L18:
.dbline 54
.dbline 55
ldi R16,43
ldi R17,0
xcall _delay_us
.dbline 56
dec R20
.dbline 57
L19:
.dbline 53
; while(time!=0)
tst R20
brne L18
.dbline -2
L17:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r time 20 c
.dbend
.dbfunc e delay_turn _delay_turn fV
; time -> R20
.even
_delay_turn::
xcall push_gset1
.dbline -1
.dbline 60
; {
; delay_us(43);
; time--;
; }
; }
; void delay_turn()//延時0.2ms,用于轉(zhuǎn)向
; {//毫秒級延時程序
.dbline 61
; unsigned char time=1;
ldi R20,1
xjmp L23
L22:
.dbline 63
.dbline 64
ldi R16,20
ldi R17,0
xcall _delay_us
.dbline 65
dec R20
.dbline 66
L23:
.dbline 62
; while(time!=0)
tst R20
brne L22
.dbline -2
L21:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r time 20 c
.dbend
.dbfunc e delay_run _delay_run fV
; time -> R20
.even
_delay_run::
xcall push_gset1
.dbline -1
.dbline 69
; {
; delay_us(20);
; time--;
; }
; }
; void delay_run()//延時1.3m,用于正轉(zhuǎn)
; {//毫秒級延時程序
.dbline 70
; unsigned char time=1;
ldi R20,1
xjmp L27
L26:
.dbline 72
.dbline 73
ldi R16,156
ldi R17,0
xcall _delay_us
.dbline 74
dec R20
.dbline 75
L27:
.dbline 71
; while(time!=0)
tst R20
brne L26
.dbline -2
L25:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r time 20 c
.dbend
.dbfunc e delay_back _delay_back fV
; time -> R20
.even
_delay_back::
xcall push_gset1
.dbline -1
.dbline 78
; {
; delay_us(156);
; time--;
; }
; }
; void delay_back()//延時1.7m,用于反轉(zhuǎn)
; {//毫秒級延時程序
.dbline 79
; unsigned char time=1;
ldi R20,1
xjmp L31
L30:
.dbline 81
.dbline 82
ldi R16,206
ldi R17,0
xcall _delay_us
.dbline 83
dec R20
.dbline 84
L31:
.dbline 80
; while(time!=0)
tst R20
brne L30
.dbline -2
L29:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r time 20 c
.dbend
.dbfunc e stop _stop fV
.even
_stop::
.dbline -1
.dbline 87
; {
; delay_us(206);
; time--;
; }
; }
; void stop(void)
; {
.dbline 88
; PORTD&=0x3f;
in R24,0x12
andi R24,63
out 0x12,R24
.dbline 89
; delay_20ms();
xcall _delay_20ms
.dbline 90
; PORTD|=0xc0;
in R24,0x12
ori R24,192
out 0x12,R24
.dbline 91
; delay_stop();
xcall _delay_stop
.dbline -2
L33:
.dbline 0 ; func end
ret
.dbend
.dbfunc e run _run fV
.even
_run::
.dbline -1
.dbline 94
; }
; void run(void)
; {
.dbline 95
; PORTD&=0x3f;
in R24,0x12
andi R24,63
out 0x12,R24
.dbline 96
; delay_20ms();
xcall _delay_20ms
.dbline 98
;
; PORTD|=0x80;
sbi 0x12,7
.dbline 99
; delay_run();
xcall _delay_run
.dbline 100
; PORTD&=0x3f;
in R24,0x12
andi R24,63
out 0x12,R24
.dbline 103
;
;
; PORTD|=0x40;
sbi 0x12,6
.dbline 104
; delay_back();
xcall _delay_back
.dbline 105
; PORTD&=0x3f;
in R24,0x12
andi R24,63
out 0x12,R24
.dbline 109
;
;
;
; delay_conver();
xcall _delay_conver
.dbline -2
L34:
.dbline 0 ; func end
ret
.dbend
.dbfunc e run_back _run_back fV
.even
_run_back::
.dbline -1
.dbline 113
;
; }
; void run_back(void)
; {
.dbline 114
; PORTD&=0x3f;
in R24,0x12
andi R24,63
out 0x12,R24
.dbline 115
; delay_20ms();
xcall _delay_20ms
.dbline 118
;
;
; PORTD|=0x80;
sbi 0x12,7
.dbline 119
; delay_back();
xcall _delay_back
.dbline 120
; PORTD&=0x3f;
in R24,0x12
andi R24,63
out 0x12,R24
.dbline 123
;
;
; PORTD|=0x40;
sbi 0x12,6
.dbline 124
; delay_run();
xcall _delay_run
.dbline 125
; PORTD&=0x3f;
in R24,0x12
andi R24,63
out 0x12,R24
.dbline 127
;
; delay_conver();
xcall _delay_conver
.dbline -2
L35:
.dbline 0 ; func end
ret
.dbend
.dbfunc e turn_left _turn_left fV
.even
_turn_left::
.dbline -1
.dbline 130
; }
; void turn_left(void)
; {
.dbline 131
; PORTD&=0x3f;
in R24,0x12
andi R24,63
out 0x12,R24
.dbline 132
; delay_20ms();
xcall _delay_20ms
.dbline 133
; PORTD|=0x80;
sbi 0x12,7
.dbline 134
; delay_run();
xcall _delay_run
.dbline 135
; PORTD&=0x3f;
in R24,0x12
andi R24,63
out 0x12,R24
.dbline -2
L36:
.dbline 0 ; func end
ret
.dbend
.dbfunc e turn_right _turn_right fV
.even
_turn_right::
.dbline -1
.dbline 139
; //delay_turn();
; }
; void turn_right(void)
; {
.dbline 140
; PORTD&=0x3f;
in R24,0x12
andi R24,63
out 0x12,R24
.dbline 141
; delay_20ms();
xcall _delay_20ms
.dbline 142
; PORTD|=0x40;
sbi 0x12,6
.dbline 143
; delay_run();
xcall _delay_run
.dbline 144
; PORTD&=0x3f;
in R24,0x12
andi R24,63
out 0x12,R24
.dbline -2
L37:
.dbline 0 ; func end
ret
.dbend
.dbfunc e display_time _display_time fV
; j -> R20
; display -> R22
; point -> R12
; second -> R10
; minute -> R14
; n1 -> R20
.even
_display_time::
xcall push_gset5
mov R14,R18
mov R20,R16
ldd R10,y+10
ldd R12,y+12
.dbline -1
.dbline 157
; //delay_turn();
; }
; /////////////////小車運(yùn)動////////////////////////////////////////
;
;
; /////////////液晶屏顯示函數(shù)/////////////////////////////////////
;
;
; void display_time(unsigned char n1,unsigned char minute,unsigned char second,unsigned char point)
; //參數(shù)n1為控制是否顯示冒號,11為不顯示,10為顯示.
; //minute\second為兩個最大為99的整數(shù)
; //point為控制是否顯示小數(shù)點(diǎn),0為不顯示,1為顯示.
; {
.dbline 159
; unsigned char j,display;
; display=number[n1];
ldi R24,<_number
ldi R25,>_number
mov R30,R20
clr R31
add R30,R24
adc R31,R25
ldd R22,z+0
.dbline 160
; for(j=0;j<8;j++)
clr R20
xjmp L42
L39:
.dbline 161
.dbline 162
sbi 0x15,4
.dbline 163
in R24,0x15
andi R24,247
out 0x15,R24
.dbline 163
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 164
mov R24,R22
andi R24,1
lsl R24
lsl R24
lsl R24
in R2,0x15
or R2,R24
out 0x15,R2
.dbline 164
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 165
in R24,0x15
andi R24,239
out 0x15,R24
.dbline 165
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 166
lsr R22
.dbline 167
L40:
.dbline 160
inc R20
L42:
.dbline 160
cpi R20,8
brlo L39
.dbline 168
; {
; PORTC|=0x10;
; PORTC&=0xf7;delay_us(5);
; PORTC|=((display&0x01)<<3);delay_us(5);
; PORTC&=0xef;delay_us(5);
; display>>=1;
; }
; display=number[minute/10];
ldi R18,10
ldi R19,0
mov R16,R14
clr R17
xcall div16s
movw R30,R16
ldi R24,<_number
ldi R25,>_number
add R30,R24
adc R31,R25
ldd R22,z+0
.dbline 169
; for(j=0;j<8;j++)
clr R20
xjmp L46
L43:
.dbline 170
.dbline 171
sbi 0x15,4
.dbline 171
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 172
in R24,0x15
andi R24,247
out 0x15,R24
.dbline 172
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 173
mov R24,R22
andi R24,1
lsl R24
lsl R24
lsl R24
in R2,0x15
or R2,R24
out 0x15,R2
.dbline 173
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 174
in R24,0x15
andi R24,239
out 0x15,R24
.dbline 174
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 175
lsr R22
.dbline 176
L44:
.dbline 169
inc R20
L46:
.dbline 169
cpi R20,8
brlo L43
.dbline 177
; {
; PORTC|=0x10;delay_us(5);
; PORTC&=0xf7;delay_us(5);
; PORTC|=((display&0x01)<<3);delay_us(5);
; PORTC&=0xef;delay_us(5);
; display>>=1;
; }
; display=number[minute%10];
ldi R18,10
ldi R19,0
mov R16,R14
clr R17
xcall mod16s
movw R30,R16
ldi R24,<_number
ldi R25,>_number
add R30,R24
adc R31,R25
ldd R22,z+0
.dbline 178
; if(point) //顯示路程時米與厘米之加小數(shù)點(diǎn)
tst R12
breq L47
.dbline 179
; display&=0x7f;
andi R22,127
L47:
.dbline 180
; for(j=0;j<8;j++)
clr R20
xjmp L52
L49:
.dbline 181
.dbline 182
sbi 0x15,4
.dbline 182
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 183
in R24,0x15
andi R24,247
out 0x15,R24
.dbline 183
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 184
mov R24,R22
andi R24,1
lsl R24
lsl R24
lsl R24
in R2,0x15
or R2,R24
out 0x15,R2
.dbline 184
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 185
in R24,0x15
andi R24,239
out 0x15,R24
.dbline 185
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 186
lsr R22
.dbline 187
L50:
.dbline 180
inc R20
L52:
.dbline 180
cpi R20,8
brlo L49
.dbline 188
; {
; PORTC|=0x10;delay_us(5);
; PORTC&=0xf7;delay_us(5);
; PORTC|=((display&0x01)<<3);delay_us(5);
; PORTC&=0xef;delay_us(5);
; display>>=1;
; }
; display=number[second/10];
ldi R18,10
ldi R19,0
mov R16,R10
clr R17
xcall div16s
movw R30,R16
ldi R24,<_number
ldi R25,>_number
add R30,R24
adc R31,R25
ldd R22,z+0
.dbline 189
; for(j=0;j<8;j++)
clr R20
xjmp L56
L53:
.dbline 190
.dbline 191
sbi 0x15,4
.dbline 191
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 192
in R24,0x15
andi R24,247
out 0x15,R24
.dbline 192
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 193
mov R24,R22
andi R24,1
lsl R24
lsl R24
in R2,0x15
or R2,R24
out 0x15,R2
.dbline 193
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 194
in R24,0x15
andi R24,239
out 0x15,R24
.dbline 194
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 195
lsr R22
.dbline 196
L54:
.dbline 189
inc R20
L56:
.dbline 189
cpi R20,8
brlo L53
.dbline 197
; {
; PORTC|=0x10;delay_us(5);
; PORTC&=0xf7;delay_us(5);
; PORTC|=((display&0x01)<<3);delay_us(5);
; PORTC&=0xef;delay_us(5);
; display>>=1;
; }
; display=number[second%10];
ldi R18,10
ldi R19,0
mov R16,R10
clr R17
xcall mod16s
movw R30,R16
ldi R24,<_number
ldi R25,>_number
add R30,R24
adc R31,R25
ldd R22,z+0
.dbline 198
; for(j=0;j<8;j++)
clr R20
xjmp L60
L57:
.dbline 199
.dbline 200
sbi 0x15,4
.dbline 200
ldi R16,5
ldi R17,0
xcall _delay_us
.dbline 201
in R24,0x15
andi R24,247
out 0x15,R24
.dbline 201
ldi R16,5
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -