📄 max144_test.s
字号:
xcall div16s
movw R24,R16
adiw R24,48
std y+0,R24
.dbline 140
ldi R18,1000
ldi R19,3
movw R16,R14
xcall mod16s
movw R14,R16
.dbline 141
; data[1]=dat/100+0x30; dat%=100;
ldi R18,100
ldi R19,0
xcall div16s
movw R24,R16
adiw R24,48
std y+1,R24
.dbline 141
ldi R18,100
ldi R19,0
movw R16,R14
xcall mod16s
movw R14,R16
.dbline 142
; data[2]=dat/10+0x30;
ldi R18,10
ldi R19,0
xcall div16s
movw R24,R16
adiw R24,48
std y+2,R24
.dbline 143
; data[3]=dat%10+0x30;
ldi R18,10
ldi R19,0
movw R16,R14
xcall mod16s
movw R24,R16
adiw R24,48
std y+3,R24
.dbline 145
;
; LCD_set_xy(X,Y);
mov R18,R12
mov R16,R10
xcall _LCD_set_xy
.dbline 146
; for(i=0;i<4;i++)
clr R20
xjmp L43
L40:
.dbline 147
; LCD_write_char(0,data[i]);
movw R24,R28
mov R30,R20
clr R31
add R30,R24
adc R31,R25
ldd R18,z+0
clr R19
clr R16
clr R17
xcall _LCD_write_char
L41:
.dbline 146
inc R20
L43:
.dbline 146
cpi R20,4
brlo L40
X8:
.dbline -2
L36:
.dbline 0 ; func end
adiw R28,4
xjmp pop_xgset30FC
.dbsym l data 0 A[4:4]c
.dbsym r i 20 c
.dbsym r dat 14 I
.dbsym r Y 12 c
.dbsym r X 10 c
.dbend
.dbfile D:\iccavr\mega16\11\max144\max144.h
.dbfunc e max144_read _max144_read fV
; adc -> y+0
; adc_temp -> R10,R11
; temp -> R12
.even
_max144_read::
xcall push_xgsetF03C
sbiw R28,4
.dbline -1
.dbline 14
; //**********ADC口线定义**********//
; #define adc_cs PA5
; #define adc_sdat PA6
; #define adc_sclk PA7
; #define adc_port PORTA
; #define adc_ddr DDRA
; #define adc_pin PINA
;
; unsigned int adc_out1,adc_out0;
; unsigned int adcttemp[2][15];
; unsigned int adcfirst[2];
;
; void max144_read(void)
; {
.dbline 16
; unsigned char temp;
; unsigned int adc_temp=0;
clr R10
clr R11
.dbline 20
; unsigned long adc;
;
; /*********max144模拟SPI口线设置**********/
; adc_port|=BIT(adc_cs)|BIT(adc_sdat)|BIT(adc_sclk);
in R24,0x1b
ori R24,224
out 0x1b,R24
.dbline 21
; adc_ddr|=BIT(adc_cs)|BIT(adc_sclk);
in R24,0x1a
ori R24,160
out 0x1a,R24
.dbline 22
; adc_ddr&=~BIT(adc_sdat);
cbi 0x1a,6
.dbline 24
;
; adc_port|=BIT(adc_cs);
sbi 0x1b,5
.dbline 25
; adc_port|=BIT(adc_sclk);
sbi 0x1b,7
.dbline 26
; adc_port&=~BIT(adc_cs);
cbi 0x1b,5
.dbline 27
; asm("nop");asm("nop");asm("nop");asm("nop");
nop
.dbline 27
nop
.dbline 27
nop
.dbline 27
nop
.dbline 28
; adc_port&=~BIT(adc_sclk);
cbi 0x1b,7
xjmp L46
L45:
.dbline 30
; while(1)
; {
.dbline 31
; if((adc_pin&BIT(adc_sdat))==BIT(adc_sdat))
in R24,0x19
andi R24,64
cpi R24,64
brne L48
X9:
.dbline 32
; break;
xjmp L47
L48:
.dbline 33
; }
L46:
.dbline 29
xjmp L45
L47:
.dbline 34
; temp=16; while(temp--)
ldi R24,16
mov R12,R24
xjmp L51
L50:
.dbline 35
; {
.dbline 36
; adc_port|=BIT(adc_sclk);
sbi 0x1b,7
.dbline 37
; if((adc_pin&BIT(adc_sdat))==BIT(adc_sdat))
in R24,0x19
andi R24,64
cpi R24,64
brne L53
X10:
.dbline 38
; adc_temp++;
movw R24,R10
adiw R24,1
movw R10,R24
L53:
.dbline 39
; adc_temp=adc_temp<<1;
lsl R10
rol R11
.dbline 40
; adc_port&=~BIT(adc_sclk);
cbi 0x1b,7
.dbline 41
; }
L51:
.dbline 34
mov R2,R12
clr R3
mov R24,R2
subi R24,1
mov R12,R24
tst R2
brne L50
X11:
.dbline 42
; adc_port|=BIT(adc_cs);
sbi 0x1b,5
.dbline 44
;
; if((adc_temp&0x2000)==0x2000)
movw R24,R10
andi R24,0
andi R25,32
cpi R24,0
ldi R26,32
cpc R25,R26
breq X15
xjmp L55
X15:
X12:
.dbline 45
; {
.dbline 46
; adcfirst[0]=(adc_temp>>1)&0xfff;
movw R24,R10
lsr R25
ror R24
andi R25,15
sts _adcfirst+1,R25
sts _adcfirst,R24
.dbline 47
; adc_temp&=0x1ffc;
movw R24,R10
andi R24,252
andi R25,31
movw R10,R24
.dbline 48
; adc=adc_temp;
movw R2,R24
clr R4
clr R5
std y+0,R2
std y+1,R3
std y+2,R4
std y+3,R5
.dbline 49
; adcttemp[0][14]=adc_temp;
sts _adcttemp+28+1,R11
sts _adcttemp+28,R10
.dbline 50
; for(temp=0;temp<14;temp++)
clr R12
xjmp L61
L58:
.dbline 51
; {
.dbline 52
; adcttemp[0][temp]=adcttemp[0][temp+1];
ldi R24,<_adcttemp
ldi R25,>_adcttemp
mov R30,R12
clr R31
adiw R30,1
lsl R30
rol R31
add R30,R24
adc R31,R25
ldd R2,z+0
ldd R3,z+1
mov R30,R12
clr R31
lsl R30
rol R31
add R30,R24
adc R31,R25
std z+1,R3
std z+0,R2
.dbline 53
; adc+=adcttemp[0][temp];
mov R30,R12
clr R31
lsl R30
rol R31
add R30,R24
adc R31,R25
ldd R2,z+0
ldd R3,z+1
clr R4
clr R5
ldd R6,y+0
ldd R7,y+1
ldd R8,y+2
ldd R9,y+3
add R6,R2
adc R7,R3
adc R8,R4
adc R9,R5
std y+0,R6
std y+1,R7
std y+2,R8
std y+3,R9
.dbline 54
; }
L59:
.dbline 50
inc R12
L61:
.dbline 50
mov R24,R12
cpi R24,14
brlo L58
X13:
.dbline 55
; adc/=15;
ldi R20,15
ldi R21,0
ldi R22,0
ldi R23,0
ldd R16,y+0
ldd R17,y+1
ldd R18,y+2
ldd R19,y+3
st -y,R23
st -y,R22
st -y,R21
st -y,R20
xcall div32u
std y+0,R16
std y+1,R17
std y+2,R18
std y+3,R19
.dbline 56
; adc_temp=adc;
ldd R10,y+0
ldd R11,y+1
.dbline 57
; adc_out1=adc>>1;
ldd R2,y+0
ldd R3,y+1
ldd R4,y+2
ldd R5,y+3
lsr R5
ror R4
ror R3
ror R2
sts _adc_out1+1,R3
sts _adc_out1,R2
.dbline 58
; }
xjmp L56
L55:
.dbline 60
; else
; {
.dbline 61
; adcfirst[1]=(adc_temp>>1)&0xfff;
movw R24,R10
lsr R25
ror R24
andi R25,15
sts _adcfirst+2+1,R25
sts _adcfirst+2,R24
.dbline 62
; adc_temp&=0x1ffc;
movw R24,R10
andi R24,252
andi R25,31
movw R10,R24
.dbline 63
; adc=adc_temp;
movw R2,R24
clr R4
clr R5
std y+0,R2
std y+1,R3
std y+2,R4
std y+3,R5
.dbline 64
; adcttemp[1][14]=adc_temp;
sts _adcttemp+30+28+1,R11
sts _adcttemp+30+28,R10
.dbline 65
; for(temp=0;temp<14;temp++)
clr R12
xjmp L68
L65:
.dbline 66
; {
.dbline 67
; adcttemp[1][temp]=adcttemp[1][temp+1];
ldi R24,<_adcttemp+30
ldi R25,>_adcttemp+30
mov R30,R12
clr R31
adiw R30,1
lsl R30
rol R31
add R30,R24
adc R31,R25
ldd R2,z+0
ldd R3,z+1
mov R30,R12
clr R31
lsl R30
rol R31
add R30,R24
adc R31,R25
std z+1,R3
std z+0,R2
.dbline 68
; adc+=adcttemp[1][temp];
mov R30,R12
clr R31
lsl R30
rol R31
add R30,R24
adc R31,R25
ldd R2,z+0
ldd R3,z+1
clr R4
clr R5
ldd R6,y+0
ldd R7,y+1
ldd R8,y+2
ldd R9,y+3
add R6,R2
adc R7,R3
adc R8,R4
adc R9,R5
std y+0,R6
std y+1,R7
std y+2,R8
std y+3,R9
.dbline 69
; }
L66:
.dbline 65
inc R12
L68:
.dbline 65
mov R24,R12
cpi R24,14
brlo L65
X14:
.dbline 70
; adc/=15;
ldi R20,15
ldi R21,0
ldi R22,0
ldi R23,0
ldd R16,y+0
ldd R17,y+1
ldd R18,y+2
ldd R19,y+3
st -y,R23
st -y,R22
st -y,R21
st -y,R20
xcall div32u
std y+0,R16
std y+1,R17
std y+2,R18
std y+3,R19
.dbline 71
; adc_temp=adc;
ldd R10,y+0
ldd R11,y+1
.dbline 72
; adc_out0=adc>>1;
ldd R2,y+0
ldd R3,y+1
ldd R4,y+2
ldd R5,y+3
lsr R5
ror R4
ror R3
ror R2
sts _adc_out0+1,R3
sts _adc_out0,R2
.dbline 73
; }
L56:
.dbline -2
L44:
.dbline 0 ; func end
adiw R28,4
xjmp pop_xgsetF03C
.dbsym l adc 0 l
.dbsym r adc_temp 10 i
.dbsym r temp 12 c
.dbend
.dbfile D:\iccavr\mega16\11\max144\max144_test.c
.dbfunc e mcu_init _mcu_init fV
.even
_mcu_init::
.dbline -1
.dbline 14
; //ICC-AVR application builder : 2008-11-4 9:30:11
; // Target : M16
; // Crystal: 8Mhz
;
; #include <iom16v.h>
; #include <macros.h>
;
;
; #include "delay.h"
; #include "lcd1602.h"
; #include "max144.h"
;
; void mcu_init(void)
; {
.dbline 15
; LCD_init();
xcall _LCD_init
.dbline -2
L72:
.dbline 0 ; func end
ret
.dbend
.dbfunc e main _main fV
.even
_main::
sbiw R28,2
.dbline -1
.dbline 19
; }
;
; void main(void)
; {
.dbline 20
; mcu_init();
xcall _mcu_init
.dbline 22
;
; LCD_write_string(0,0,"MAX144 ADC0: ");
ldi R24,<L74
ldi R25,>L74
std y+1,R25
std y+0,R24
clr R18
clr R16
xcall _LCD_write_string
.dbline 23
; LCD_write_string(0,1,"MAX144 ADC1: ");
ldi R24,<L75
ldi R25,>L75
std y+1,R25
std y+0,R24
ldi R18,1
clr R16
xcall _LCD_write_string
xjmp L77
L76:
.dbline 25
; while(1)
; {
.dbline 26
; max144_read();
xcall _max144_read
.dbline 27
; LCD_write_data(12,0,adc_out0);
lds R2,_adc_out0
lds R3,_adc_out0+1
std y+1,R3
std y+0,R2
clr R18
ldi R16,12
xcall _LCD_write_data
.dbline 28
; LCD_write_data(12,1,adc_out1);
lds R2,_adc_out1
lds R3,_adc_out1+1
std y+1,R3
std y+0,R2
ldi R18,1
ldi R16,12
xcall _LCD_write_data
.dbline 29
; }
L77:
.dbline 24
xjmp L76
X16:
.dbline -2
L73:
.dbline 0 ; func end
adiw R28,2
ret
.dbend
.area bss(ram, con, rel)
.dbfile D:\iccavr\mega16\11\max144\max144_test.c
_adcfirst::
.blkb 4
.dbfile D:\iccavr\mega16\11\max144\max144.h
.dbsym e adcfirst _adcfirst A[4:2]i
_adcttemp::
.blkb 60
.dbsym e adcttemp _adcttemp A[60:2:15]i
_adc_out0::
.blkb 2
.dbsym e adc_out0 _adc_out0 i
_adc_out1::
.blkb 2
.dbsym e adc_out1 _adc_out1 i
.area data(ram, con, rel)
.dbfile D:\iccavr\mega16\11\max144\max144.h
L75:
.blkb 17
.area idata
.byte 'M,'A,'X,49,52,52,32,'A,'D,'C,49,58,32,32,32,32
.byte 0
.area data(ram, con, rel)
.dbfile D:\iccavr\mega16\11\max144\max144.h
L74:
.blkb 17
.area idata
.byte 'M,'A,'X,49,52,52,32,'A,'D,'C,48,58,32,32,32,32
.byte 0
.area data(ram, con, rel)
.dbfile D:\iccavr\mega16\11\max144\max144.h
; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -