?? 1602test.s
字號(hào):
.module _1602test.c
.area data(ram, con, rel)
_str1::
.blkb 17
.area idata
.byte 'N,'O,49,58,32,32,32,32,32,'N,'O,50,58,32,32,32
.byte 0
.area data(ram, con, rel)
.dbfile D:\醫(yī)療電子采樣板\1602test\1602test.c
.dbsym e str1 _str1 A[17:17]c
_str2::
.blkb 17
.area idata
.byte 'N,'O,51,58,32,32,32,32,32,'N,'O,52,58,32,32,32
.byte 0
.area data(ram, con, rel)
.dbfile D:\醫(yī)療電子采樣板\1602test\1602test.c
.dbsym e str2 _str2 A[17:17]c
.area lit(rom, con, rel)
_t_per::
.byte 153,153
.byte 153,153
.byte 153,153
.byte 153,153
.byte 153,153
.byte 153,153
.byte 153,153
.byte 152,151
.byte 150,149
.byte 148,147
.byte 146,144
.byte 137,136
.byte 134,133
.byte 132,131
.byte 130,129
.byte 128,'x
.byte 'w,'v
.byte 'u,'t
.byte 's,'r
.byte 'q,'p
.byte 'p,'i
.byte 'h,'g
.byte 'f,'e
.byte 'd,'c
.byte 'b,'a
.byte 96,'Y
.byte 'X,'X
.byte 'W,'W
.byte 'V,'V
.byte 'U,'U
.byte 'T,'S
.byte 'S,'R
.byte 'Q,'P
.byte 'P,'I
.byte 'I,'H
.byte 'H,'H
.byte 'G,'G
.byte 'F,'F
.byte 'E,'E
.byte 'D,'D
.byte 'D,'C
.byte 'C,'C
.byte 'B,'B
.byte 'A,'A
.byte 64,64
.byte 64,57
.byte 57,56
.byte 56,55
.byte 55,55
.byte 54,54
.byte 53,53
.byte 53,52
.byte 52,51
.byte 51,51
.byte 50,50
.byte 50,49
.byte 49,48
.byte 48,48
.byte 41,41
.byte 40,40
.byte 39,39
.byte 39,39
.byte 38,38
.byte 38,37
.byte 37,36
.byte 36,36
.byte 35,35
.byte 35,34
.byte 34,34
.byte 33,33
.byte 33,32
.byte 32,32
.byte 25,25
.byte 25,24
.byte 24,24
.byte 23,23
.byte 22,22
.byte 22,21
.byte 21,21
.byte 20,20
.byte 20,19
.byte 19,19
.byte 18,18
.byte 18,17
.byte 17,17
.byte 16,16
.byte 9,9
.byte 9,8
.byte 8,7
.byte 7,6
.byte 6,6
.byte 5,5
.byte 5,4
.byte 4,3
.byte 3,2
.byte 2,1
.byte 1,0
.byte 0,0
.byte 0,1
.byte 1,2
.byte 2,3
.byte 3,4
.byte 4,3
.byte 5,5
.byte 5,6
.byte 7,8
.byte 9,9
.byte 16,16
.byte 17,17
.byte 18,18
.byte 19,19
.byte 20,20
.byte 21,21
.byte 22,22
.byte 23,23
.byte 24,24
.byte 25,32
.byte 33,34
.byte 35,36
.byte 37,38
.byte 39,40
.byte 41,48
.byte 49,50
.byte 51,52
.byte 53,54
.byte 55,56
.byte 57,64
.byte 'P
.dbsym e t_per _t_per A[255:255]kc
.area text(rom, con, rel)
.dbfile D:\醫(yī)療電子采樣板\1602test\1602test.c
.dbfunc e main _main fV
.even
_main::
.dbline -1
.dbline 80
; //ICC-AVR application builder : 2006-11-14 10:39:01
; // Target : M16
; // Crystal: 4.0000Mhz
;
; #include <iom16v.h>
; #include <macros.h>
; #define vfd_data_port PORTB
; #define vfd_data_ddr DDRB
; #define vfd_busy_pin PINB
; #define vfd_busy_ddr DDRB
; #define vfd_control_port PORTD
; #define vfd_control_ddr DDRD
; #define vfd_RS 0x20 //PORTD^5
; #define vfd_EN 0x40 //PORTD^6
; #define vfd_RW 0x80 //PORTD^7
; //#define vfd_RW 0x40 //PORTD^1
; //#define vfd_EN 0x80 //PORTD^2
; #define busy 0x80 //VFD_DB7
; struct sem
; {
; unsigned int ad_samp; //a/d sampling data
; unsigned int pc_trans; //pc transfer to chip
; unsigned char class_addr[4]; //data addr
; unsigned char class_data[7]; //asc ii code from pc to chip or chip to pc
; }dypass[9];
; unsigned char adc_mux,i;
; unsigned int adc_rel,adc_old,sin;
; unsigned char adc_meas[20];
; unsigned char hex_meas[5];
; unsigned char rece_coun;
; unsigned char meas_coun;
; unsigned char *point;
; unsigned char channel;//sampling channel
; /*----------------------------------函數(shù)聲明------------------------------------------*/
; void vfd_init(void);
; void vfd_write_command(unsigned char command,unsigned char wait_en);
; void vfd_write_data(unsigned char char_data);
; void wait_enable(void);
; void display_a_char(unsigned char position,unsigned char char_data);
; void d_a_s(unsigned char col,unsigned char *ptr);
; void display_a_ch_r(unsigned char position,unsigned char char_data);
; void delay_1ms(void);
; void delay_nms(unsigned int n);
; void adc_init(void);
; void filter(unsigned char maj);
; void hex_asc(unsigned int dt_meas,unsigned char *g);
; //顯示的兩行字符
; unsigned char str1[]="NO1: NO2: ";
; unsigned char str2[]="NO3: NO4: ";
; const unsigned char t_per[255]={
; 0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,//0~9
; 0x99,0x99,0x99,0x99,0x98,0x97,0x96,0x95,0x94,0x93,//10~19
; 0x92,0x90,0x89,0x88,0x86,0x85,0x84,0x83,0x82,0x81,//20~29
; 0x80,0x78,0x77,0x76,0x75,0x74,0x73,0x72,0x71,0x70,//30~39
; 0x70,0x69,0x68,0x67,0x66,0x65,0x64,0x63,0x62,0x61,//40~49
; 0x60,0x59,0x58,0x58,0x57,0x57,0x56,0x56,0x55,0x55,//50~59
; 0x54,0x53,0x53,0x52,0x51,0x50,0x50,0x49,0x49,0x48,//60~69
; 0x48,0x48,0x47,0x47,0x46,0x46,0x45,0x45,0x44,0x44,//70~79
; 0x44,0x43,0x43,0x43,0x42,0x42,0x41,0x41,0x40,0x40,//80~89
; 0x40,0x39,0x39,0x38,0x38,0x37,0x37,0x37,0x36,0x36,//90~99
; 0x35,0x35,0x35,0x34,0x34,0x33,0x33,0x33,0x32,0x32,//100~109
; 0x32,0x31,0x31,0x30,0x30,0x30,0x29,0x29,0x28,0x28,//110~119
; 0x27,0x27,0x27,0x27,0x26,0x26,0x26,0x25,0x25,0x24,//120~129
; 0x24,0x24,0x23,0x23,0x23,0x22,0x22,0x22,0x21,0x21,//130~139
; 0x21,0x20,0x20,0x20,0x19,0x19,0x19,0x18,0x18,0x18,//140~149
; 0x17,0x17,0x16,0x16,0x16,0x15,0x15,0x15,0x14,0x14,//150~159
; 0x14,0x13,0x13,0x13,0x12,0x12,0x12,0x11,0x11,0x11,//160~169
; 0x10,0x10,0x9,0x9,0x9,0x8,0x8,0x7,0x7,0x6,//170~179
; 0x6,0x6,0x5,0x5,0x5,0x4,0x4,0x3,0x3,0x2,//180~189
; 0x2,0x1,0x1,0x0,0x0,0x0,0x0,0x1,0x1,0x2,//190~199
; 0x2,0x3,0x3,0x4,0x4,0x3,0x5,0x5,0x5,0x6,//200~209
; 0x7,0x8,0x9,0x9,0x10,0x10,0x11,0x11,0x12,0x12,//210~219
; 0x13,0x13,0x14,0x14,0x15,0x15,0x16,0x16,0x17,0x17,//220~229
; 0x18,0x18,0x19,0x20,0x21,0x22,0x23,0x24,0x25,0x26,//230~239
; 0x27,0x28,0x29,0x30,0x31,0x32,0x33,0x34,0x35,0x36,//240~249
; 0x37,0x38,0x39,0x40,0x50,};//250~254
; /*------------------------------------主函數(shù)-------------------------------------------*/
; //在VFD上顯示hello和www.xmbyte.com兩行字符
; void main(void)
; {
.dbline 81
; adc_init();
xcall _adc_init
.dbline 82
; vfd_data_port=0xff;
ldi R24,255
out 0x18,R24
.dbline 83
; vfd_data_ddr=0xff;
out 0x17,R24
.dbline 84
; vfd_control_port=0xF0;
ldi R24,240
out 0x12,R24
.dbline 85
; vfd_control_ddr=0xF0;
out 0x11,R24
.dbline 86
; DDRC = 0xFF;
ldi R24,255
out 0x14,R24
.dbline 87
; PORTC = 0xff; //m103 output only
out 0x15,R24
.dbline 89
;
; vfd_init();
xcall _vfd_init
xjmp L3
L2:
.dbline 93
; //d_a_s(0,str1);
; //d_a_s(1,str2);
; while(1)
; {
.dbline 94
; PORTC=0XFF;
ldi R24,255
out 0x15,R24
.dbline 95
; vfd_write_command(0xf,1);
ldi R18,1
ldi R16,15
xcall _vfd_write_command
.dbline 96
; vfd_write_command(0x6,1);
ldi R18,1
ldi R16,6
xcall _vfd_write_command
.dbline 97
; d_a_s(0,str1);
ldi R18,<_str1
ldi R19,>_str1
clr R16
xcall _d_a_s
.dbline 100
;
; //A/D 采樣四個(gè)通道
; filter(0);
clr R16
xcall _filter
.dbline 101
; filter(1);
ldi R16,1
xcall _filter
.dbline 102
; filter(2);
ldi R16,2
xcall _filter
.dbline 103
; filter(3);
ldi R16,3
xcall _filter
.dbline 104
; sin=4;
ldi R24,4
ldi R25,0
sts _sin+1,R25
sts _sin,R24
.dbline 105
; for(i=2;i<=3;i++)
ldi R24,2
sts _i,R24
xjmp L8
L5:
.dbline 106
.dbline 107
ldi R24,<_dypass+8
ldi R25,>_dypass+8
lds R30,_i
clr R31
add R30,R24
adc R31,R25
ldd R2,z+0
ldi R24,<_str1
ldi R25,>_str1
lds R30,_sin
lds R31,_sin+1
add R30,R24
adc R31,R25
std z+0,R2
.dbline 108
lds R24,_sin
lds R25,_sin+1
adiw R24,1
sts _sin+1,R25
sts _sin,R24
.dbline 109
L6:
.dbline 105
lds R24,_i
subi R24,255 ; addi 1
sts _i,R24
L8:
.dbline 105
ldi R24,3
lds R2,_i
cp R24,R2
brsh L5
.dbline 110
; {
; str1[sin]=dypass[0].class_data[i];
; sin++;
; }
; str1[6]=0x1a;
ldi R24,26
sts _str1+6,R24
.dbline 111
; sin=13;
ldi R24,13
ldi R25,0
sts _sin+1,R25
sts _sin,R24
.dbline 112
; for(i=2;i<=3;i++)
ldi R24,2
sts _i,R24
xjmp L14
L11:
.dbline 113
.dbline 114
ldi R24,<_dypass+15+8
ldi R25,>_dypass+15+8
lds R30,_i
clr R31
add R30,R24
adc R31,R25
ldd R2,z+0
ldi R24,<_str1
ldi R25,>_str1
lds R30,_sin
lds R31,_sin+1
add R30,R24
adc R31,R25
std z+0,R2
.dbline 115
lds R24,_sin
lds R25,_sin+1
adiw R24,1
sts _sin+1,R25
sts _sin,R24
.dbline 116
L12:
.dbline 112
lds R24,_i
subi R24,255 ; addi 1
sts _i,R24
L14:
.dbline 112
ldi R24,3
lds R2,_i
cp R24,R2
brsh L11
.dbline 117
; {
; str1[sin]=dypass[1].class_data[i];
; sin++;
; }
; str1[15]=0x1a;
ldi R24,26
sts _str1+15,R24
.dbline 118
; sin=4;
ldi R24,4
ldi R25,0
sts _sin+1,R25
sts _sin,R24
.dbline 119
; for(i=2;i<=3;i++)
ldi R24,2
sts _i,R24
xjmp L21
L18:
.dbline 120
.dbline 121
ldi R24,<_dypass+30+8
ldi R25,>_dypass+30+8
lds R30,_i
clr R31
add R30,R24
adc R31,R25
ldd R2,z+0
ldi R24,<_str2
ldi R25,>_str2
lds R30,_sin
lds R31,_sin+1
add R30,R24
adc R31,R25
std z+0,R2
.dbline 122
lds R24,_sin
lds R25,_sin+1
adiw R24,1
sts _sin+1,R25
sts _sin,R24
.dbline 123
L19:
.dbline 119
lds R24,_i
subi R24,255 ; addi 1
sts _i,R24
L21:
.dbline 119
ldi R24,3
lds R2,_i
cp R24,R2
brsh L18
.dbline 124
; {
; str2[sin]=dypass[2].class_data[i];
; sin++;
; }
; str2[6]=0x1a;
ldi R24,26
sts _str2+6,R24
.dbline 125
; sin=13;
ldi R24,13
ldi R25,0
sts _sin+1,R25
sts _sin,R24
.dbline 126
; for(i=2;i<=3;i++)
ldi R24,2
sts _i,R24
xjmp L28
L25:
.dbline 127
.dbline 128
ldi R24,<_dypass+45+8
ldi R25,>_dypass+45+8
lds R30,_i
clr R31
add R30,R24
adc R31,R25
ldd R2,z+0
ldi R24,<_str2
ldi R25,>_str2
lds R30,_sin
lds R31,_sin+1
add R30,R24
adc R31,R25
std z+0,R2
.dbline 129
lds R24,_sin
lds R25,_sin+1
adiw R24,1
sts _sin+1,R25
sts _sin,R24
.dbline 130
L26:
.dbline 126
lds R24,_i
subi R24,255 ; addi 1
sts _i,R24
L28:
.dbline 126
ldi R24,3
lds R2,_i
cp R24,R2
brsh L25
.dbline 131
ldi R24,26
sts _str2+15,R24
.dbline 132
ldi R18,<_str1
ldi R19,>_str1
clr R16
xcall _d_a_s
.dbline 133
ldi R18,<_str2
ldi R19,>_str2
ldi R16,1
xcall _d_a_s
.dbline 135
ldi R16,1000
ldi R17,3
xcall _delay_nms
.dbline 136
clr R2
out 0x15,R2
.dbline 137
ldi R16,1000
ldi R17,3
xcall _delay_nms
.dbline 138
ldi R18,<_str2
ldi R19,>_str2
ldi R16,1
xcall _d_a_s
.dbline 139
L3:
.dbline 92
xjmp L2
X0:
.dbline -2
.dbline 140
; {
; str2[sin]=dypass[3].class_data[i];
; sin++;
; }
; str2[15]=0x1a;
; d_a_s(0,str1);
; d_a_s(1,str2);
;
; delay_nms(1000);
; PORTC=0X00;
; delay_nms(1000);
; d_a_s(1,str2);
; }
; }
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e adc_init _adc_init fV
.even
_adc_init::
.dbline -1
.dbline 142
; void adc_init(void)
; {
.dbline 143
; DDRA=0x00;
clr R2
out 0x1a,R2
.dbline 144
; PORTA=0x00;
out 0x1b,R2
.dbline 145
; ADCSRA = 0x00;
out 0x6,R2
.dbline 146
; ADMUX =(1<<REFS0)|(adc_mux&0x0f);//選擇內(nèi)部AVCC為基準(zhǔn)
lds R24,_adc_mux
andi R24,15
ori R24,64
out 0x7,R24
.dbline 147
; ACSR =(1<<ACD);//關(guān)閉模擬比較器
ldi R24,128
out 0x8,R24
.dbline 148
; ADCSRA=(1<<ADEN)|(1<<ADSC)|(1<<ADPS2)|(1<<ADPS1) ;//64分頻
ldi R24,198
out 0x6,R24
.dbline -2
.dbline 149
; }
L32:
.dbline 0 ; func end
ret
.dbend
.dbfunc e hex_asc _hex_asc fV
; g -> R20,R21
; dt_meas -> R22,R23
.even
_hex_asc::
xcall push_gset2
movw R20,R18
movw R22,R16
.dbline -1
.dbline 153
;
; //將無符號(hào)的整形數(shù)轉(zhuǎn)換為asc碼,保存于指針g開始的連續(xù)四個(gè)空間
; void hex_asc(unsigned int dt_meas,unsigned char *g)
; {
.dbline 154
; *g=(unsigned char)(dt_meas/0x1000);
ldi R18,12
ldi R19,0
movw R16,R22
xcall lsr16
movw R30,R20
std z+0,R16
.dbline 155
; if(*g<10)
ldd R24,z+0
cpi R24,10
brsh L34
.dbline 156
; *g+=0x30;
subi R24,208 ; addi 48
std z+0,R24
xjmp L35
L34:
.dbline 157
; else *g+=0x37;
movw R30,R20
ldd R24,z+0
subi R24,201 ; addi 55
std z+0,R24
L35:
.dbline 158
; g++;
subi R20,255 ; offset = 1
sbci R21,255
.dbline 159
; *g=(unsigned char)((dt_meas/0x100)%0x10);
movw R24,R22
mov R24,R25
clr R25
andi R24,15
andi R25,0
movw R30,R20
std z+0,R24
.dbline 160
; if(*g<10)
cpi R24,10
brsh L36
.dbline 161
; *g+=0x30;
subi R24,208 ; addi 48
std z+0,R24
xjmp L37
L36:
.dbline 162
; else *g+=0x37;
movw R30,R20
ldd R24,z+0
subi R24,201 ; addi 55
std z+0,R24
L37:
.dbline 163
; g++;
subi R20,255 ; offset = 1
sbci R21,255
.dbline 164
; *g=(dt_meas%0x100)/0x10;
movw R24,R22
andi R25,0
lsr R25
ror R24
lsr R25
ror R24
lsr R25
ror R24
lsr R25
ror R24
movw R30,R20
std z+0,R24
.dbline 165
; if(*g<10)
cpi R24,10
brsh L38
.dbline 166
; *g+=0x30;
subi R24,208 ; addi 48
std z+0,R24
xjmp L39
L38:
.dbline 167
; else *g+=0x37;
movw R30,R20
ldd R24,z+0
subi R24,201 ; addi 55
std z+0,R24
L39:
.dbline 168
; g++;
subi R20,255 ; offset = 1
sbci R21,255
.dbline 169
; *g=(dt_meas%0x100)%0x10;
movw R24,R22
andi R24,15
andi R25,0
movw R30,R20
std z+0,R24
.dbline 170
; if(*g<10)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -