📄 fas.s
字号:
.module fas.c
.area data(ram, con, rel)
_ndata::
.blkb 2
.area idata
.byte 251,134
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 'U,'U
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 'U,'U
.area data(ram, con, rel)
.blkb 1
.area idata
.byte 'U
.area data(ram, con, rel)
.dbfile fas.c
.dbsym e ndata _ndata A[7:7]c
.area text(rom, con, rel)
.dbfile fas.c
.dbfunc e delay _delay fV
; j -> R20
; x -> R16,R17
.even
_delay::
rcall push_gset1
.dbline -1
.dbline 56
; /**********************************/
; /* 汽车转速测量程序
; /* 8.24,2004
; /* Writed by Wuxw
; /* Automation Depart. of WHUT
; /* 芯片:ATMEGA8L
; /* 晶振:2MHz
; /*
; /*
; /***********************************/
; /* 脉冲输入接在INT0端口
; /*
; /* 输出n,单位r/50ms,可用来计算车轮转速
; /*
; /* num----脉冲计数,可用来计算里程
; /*
; /* 485输出格式:FB-86-n-numLL-numLH-numHL-numHH-checksum
; /*
; /* numLL-numLH-numHL-numHH分别为num的四个字节(L为低字节,H为高字节)
; /*
; /* 串口485通讯波特率baud = 9600
; /*
; /* 在受到正确地址(0x32)和命令(0xc5)后,发送数据
; /*
; /***********************************/
;
;
;
; #include "iom8v.h"
; #include "macros.h"
; #define uchar unsigned char
; #define uint unsigned int
; #define ulong unsigned long
;
; #define E2ADDRLL 0x000 //脉冲计数存放地址
; #define E2ADDRLH 0x001
; #define E2ADDRHL 0x002
; #define E2ADDRHH 0x003
; //#define osccal 0x9d//内部RC 校正常数
; #define osccal_addr 0x1ff
; //#define osccal 0xa4 //内部RC校正常数
; #define fosc 8000000 //晶振8MHZ
; #define baud 9600 //串口通讯波特率
; #define TIME50ms 0xae //定时50ms的初装值
;
; //#define osccal_addr 0x1ff
;
; uint m,n,K,i;
; //uchar ndata[7]={0xFB,0x86,0x00,0x11,0x22,0x33,044};
; uchar ndata[7]={0xFB,0x86,0x55,0x55,0x55,0x55,0x55};
;
;
;
; //最小延时单位,约16微秒
; void delay(uint x)
; { uchar j;
rjmp L3
L2:
.dbline 58
; while(x-->0)
; {
.dbline 59
; for(j=0;j<5;j++)
clr R20
rjmp L8
L5:
.dbline 60
.dbline 60
.dbline 60
L6:
.dbline 59
inc R20
L8:
.dbline 59
cpi R20,5
brlo L5
.dbline 61
L3:
.dbline 57
movw R2,R16
subi R16,1
sbci R17,0
tst R2
brne L2
tst R3
brne L2
X0:
.dbline -2
.dbline 62
; {;}
; }
; }
L1:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r j 20 c
.dbsym r x 16 i
.dbend
.dbfunc e EEPROM_read _EEPROM_read fc
; uiAddress -> R16,R17
.even
_EEPROM_read::
.dbline -1
.dbline 65
L10:
.dbline 65
L11:
.dbline 65
;
; unsigned char EEPROM_read(unsigned int uiAddress)
; {while(EECR&(1<<EEWE));
sbic 0x1c,1
rjmp L10
.dbline 66
; EEAR=uiAddress;
out 0x1f,R17
out 0x1e,R16
.dbline 67
; EECR|=(1<<EERE);
sbi 0x1c,0
.dbline 68
; return EEDR;
in R16,0x1d
.dbline -2
L9:
.dbline 0 ; func end
ret
.dbsym r uiAddress 16 i
.dbend
.area vector(rom, abs)
.org 26
rjmp _uart0_tx_isr
.area text(rom, con, rel)
.dbfile fas.c
.dbfunc e uart0_tx_isr _uart0_tx_isr fV
.even
_uart0_tx_isr::
st -y,R2
st -y,R3
st -y,R24
st -y,R25
st -y,R30
st -y,R31
in R2,0x3f
st -y,R2
.dbline -1
.dbline 73
; }
;
; #pragma interrupt_handler uart0_tx_isr:iv_USART_TXC
; void uart0_tx_isr(void)
; {
.dbline 75
;
; if(K<6)
lds R24,_K
lds R25,_K+1
cpi R24,6
ldi R30,0
cpc R25,R30
brsh L14
.dbline 76
; {K=K+1;
.dbline 76
adiw R24,1
sts _K+1,R25
sts _K,R24
.dbline 77
; UDR=ndata[K];
ldi R24,<_ndata
ldi R25,>_ndata
lds R30,_K
lds R31,_K+1
add R30,R24
adc R31,R25
ldd R2,z+0
out 0xc,R2
.dbline 78
; }
rjmp L15
L14:
.dbline 81
.dbline 82
clr R2
clr R3
sts _K+1,R3
sts _K,R2
.dbline 83
cbi 0xa,6
.dbline 84
L15:
.dbline -2
.dbline 87
;
; else
; {
; K=0;
; UCSRB&=~(1<<TXCIE); //1?UART ?¤?é?¨a?D??
; }
;
;
; }
L13:
ld R2,y+
out 0x3f,R2
ld R31,y+
ld R30,y+
ld R25,y+
ld R24,y+
ld R3,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.dbfunc e USART_Init _USART_Init fV
.even
_USART_Init::
.dbline -1
.dbline 90
;
; void USART_Init(void) //串行初始化
; {
.dbline 91
; UCSRB|=(1<<TXEN);//允许发送
sbi 0xa,3
.dbline 92
; UBRRL=(fosc/16/(baud+1))%256; //波特率的设置
ldi R24,52
out 0x9,R24
.dbline 93
; UBRRH=(fosc/16/(baud+1))/256;
clr R2
out 0x20,R2
.dbline 94
; UCSRC=0x86;//8 位数据+1 位STOP 位
ldi R24,134
out 0x20,R24
.dbline -2
.dbline 95
; }
L16:
.dbline 0 ; func end
ret
.dbend
.dbfunc e main _main fV
.even
_main::
.dbline -1
.dbline 98
;
; void main(void)
; {
.dbline 99
; delay(200);
ldi R16,200
ldi R17,0
rcall _delay
.dbline 100
; OSCCAL=EEPROM_read(osccal_addr);
ldi R16,511
ldi R17,1
rcall _EEPROM_read
out 0x31,R16
.dbline 103
; //OSCCAL=osccal;
;
; PORTD|=(1<<PORTD7);
sbi 0x12,7
.dbline 104
; USART_Init();
rcall _USART_Init
.dbline 106
;
; DDRD|=0x80;
sbi 0x11,7
.dbline 108
;
; SEI();
sei
rjmp L19
L18:
.dbline 112
;
;
; while(1)
; {
.dbline 113
; UCSRB|=(1<<TXCIE);
sbi 0xa,6
.dbline 114
; UDR=ndata[0];
lds R2,_ndata
out 0xc,R2
.dbline 115
; for(i=0;i<250;i++)
clr R2
clr R3
sts _i+1,R3
sts _i,R2
rjmp L24
L21:
.dbline 116
.dbline 116
ldi R16,1000
ldi R17,3
rcall _delay
.dbline 116
L22:
.dbline 115
lds R24,_i
lds R25,_i+1
adiw R24,1
sts _i+1,R25
sts _i,R24
L24:
.dbline 115
lds R24,_i
lds R25,_i+1
cpi R24,250
ldi R30,0
cpc R25,R30
brlo L21
.dbline 118
L19:
.dbline 111
rjmp L18
X1:
.dbline -2
.dbline 119
; {delay(1000);}
;
; }
; }
L17:
.dbline 0 ; func end
ret
.dbend
.area bss(ram, con, rel)
.dbfile fas.c
_i::
.blkb 2
.dbsym e i _i i
_K::
.blkb 2
.dbsym e K _K i
_n::
.blkb 2
.dbsym e n _n i
_m::
.blkb 2
.dbsym e m _m i
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -