📄 main.s
字号:
.dbline 106
clr R2
sts _tx_rd_index0,R2
L28:
.dbline 107
; };
L26:
.dbline 107
.dbline -2
L25:
.dbline 0 ; func end
ld R2,y+
out 0x3f,R2
ld R31,y+
ld R30,y+
ld R25,y+
ld R24,y+
ld R2,y+
reti
.dbend
.dbfunc e putchar _putchar fV
; IisOn -> R20
; c -> R16
.even
_putchar::
st -y,R20
.dbline -1
.dbline 114
; }
;
;
;
; // Write a character to the USART0 Transmitter buffer
; void putchar(char c)
; {
.dbline 115
; char IisOn = 1;
ldi R20,1
.dbline 116
; if((SREG & 0x80) == 0x00) //I之前是否置位
in R2,0x3f
sbrc R2,7
rjmp L34
X12:
.dbline 117
; IisOn = 0;
clr R20
L33:
.dbline 118
; while (tx_counter0 == TX_BUFFER_SIZE0);
L34:
.dbline 118
lds R24,_tx_counter0
cpi R24,20
breq L33
X13:
.dbline 119
; CLI();
cli
.dbline 120
; if (tx_counter0 || ((UCSR0A & DATA_REGISTER_EMPTY)==0))
lds R2,_tx_counter0
tst R2
brne L38
X14:
lds R2,192
sbrc R2,5
rjmp L36
X15:
L38:
.dbline 121
; {
.dbline 122
; tx_buffer0[tx_wr_index0]=c;
ldi R24,<_tx_buffer0
ldi R25,>_tx_buffer0
lds R30,_tx_wr_index0
clr R31
add R30,R24
adc R31,R25
std z+0,R16
.dbline 123
; if (++tx_wr_index0 == TX_BUFFER_SIZE0) tx_wr_index0=0;
lds R24,_tx_wr_index0
subi R24,255 ; addi 1
mov R2,R24
sts _tx_wr_index0,R2
cpi R24,20
brne L39
X16:
.dbline 123
clr R2
sts _tx_wr_index0,R2
L39:
.dbline 124
; ++tx_counter0;
lds R24,_tx_counter0
subi R24,255 ; addi 1
sts _tx_counter0,R24
.dbline 125
; }
rjmp L37
L36:
.dbline 127
; else
; UDR0=c;
sts 198,R16
L37:
.dbline 128
; if(IisOn)
tst R20
breq L41
X17:
.dbline 129
; SEI();
sei
L41:
.dbline -2
L30:
.dbline 0 ; func end
ld R20,y+
ret
.dbsym r IisOn 20 c
.dbsym r c 16 c
.dbend
.dbfunc e DisposeBufDatas _DisposeBufDatas fV
; spray2NumH -> R14
; spray2NumL -> R12
; spray1NumH -> y+6
; spray1NumL -> y+5
; tPump1On -> R10
; tSpray1Cyc -> y+3
; tSpray1On -> y+2
; tPump1Cyc -> y+1
; IisOn -> y+0
.even
_DisposeBufDatas::
rcall push_xgsetF0FC
sbiw R28,7
.dbline -1
.dbline 133
; }
;
; void DisposeBufDatas(void)
; {
.dbline 150
; //定义变量
; unsigned char tPump1Cyc; //油泵1周期,单位ms
; unsigned char tSpray1On; //喷射脉宽,单位0.1ms
; //unsigned char tSpray1OnH;
; unsigned int tSpray1Cyc; //喷射周期,单位ms
; unsigned char tPump1On; //油泵1脉宽,单位0.1ms
; char spray1NumL; //SprayNum低字节
; char spray1NumH; //SprayNum高字节
;
; //unsigned char tPump2Cyc; //油泵2周期,单位ms
; //unsigned char tSpray2On; //喷射脉宽,单位0.1ms
; //unsigned int tSpray2Cyc; //喷射周期,单位ms
; //unsigned char tPump2On; //油泵2脉宽,单位0.1ms
; char spray2NumL; //SprayNum低字节
; char spray2NumH; //SprayNum高字节
;
; char IisOn = 1;
clr R0
inc R0
std y+0,R0
.dbline 151
; if((SREG & 0x80) == 0x00) //I之前是否置位
in R2,0x3f
sbrc R2,7
rjmp L44
X18:
.dbline 152
; IisOn = 0;
clr R0
std y+0,R0
L44:
.dbline 154
;
; if(rx_error0) //接收错误
lds R2,_rx_error0
tst R2
breq L46
X19:
.dbline 155
; {
.dbline 156
; CLI();
cli
.dbline 157
; putchar(SENDAGAIN);
ldi R16,254
rcall _putchar
.dbline 158
; putchar(SENDAGAIN);
ldi R16,254
rcall _putchar
.dbline 159
; if(IisOn)
ldd R0,y+0
tst R0
brne X22
rjmp L47
X22:
X20:
.dbline 160
; SEI();
sei
.dbline 161
; }
rjmp L47
L46:
.dbline 163
; else
; {
.dbline 164
; spray1NumL = getchar();
rcall _getchar
std y+5,R16
.dbline 165
; spray1NumH = getchar();
rcall _getchar
std y+6,R16
.dbline 166
; tSpray1On = getchar();
rcall _getchar
mov R10,R16
std y+2,R10
.dbline 167
; tSpray1Cyc = getchar();
rcall _getchar
mov R10,R16
mov R2,R10
clr R3
std y+4,R3
std y+3,R2
.dbline 168
; tPump1Cyc = getchar();
rcall _getchar
mov R10,R16
std y+1,R10
.dbline 169
; tPump1On = getchar();
rcall _getchar
mov R10,R16
.dbline 171
;
; spray2NumL = getchar();
rcall _getchar
mov R12,R16
.dbline 172
; spray2NumH = getchar();
rcall _getchar
mov R14,R16
.dbline 189
; //tSpray2On = getchar();
; //tSpray2Cyc = getchar();
; //tPump2Cyc = getchar();
; //tPump2On = getchar();
;
; /************debug*****************/
; //putchar(sprayNumL); //debug
; //putchar(sprayNumH); //debug
; // putchar(tPump1Cyc); //debug
; //putchar(tSprayOn); //debug
; //putchar(tSprayCyc); //debug
; //putchar(tPivDelay); //debug
;
; //**********************************/
;
; //转换数据
; Pump1Num = (int)spray1NumL + ((int)spray1NumH << 8);
ldd R2,y+6
clr R3
mov R3,R2
clr R2
ldd R4,y+5
clr R5
add R4,R2
adc R5,R3
movw R2,R4
clr R4
sbrc R3,7
com R4
clr R5
sbrc R4,7
com R5
sts _Pump1Num+1,R3
sts _Pump1Num,R2
sts _Pump1Num+2+1,R5
sts _Pump1Num+2,R4
.dbline 190
; PPump1Num = Pump1Num;
sts _PPump1Num+1,R3
sts _PPump1Num,R2
sts _PPump1Num+2+1,R5
sts _PPump1Num+2,R4
.dbline 191
; Spray1Num = Pump1Num ;
sts _Spray1Num+1,R3
sts _Spray1Num,R2
sts _Spray1Num+2+1,R5
sts _Spray1Num+2,R4
.dbline 192
; SSpray1Num = Spray1Num;
lds R4,_Spray1Num+2
lds R5,_Spray1Num+2+1
lds R2,_Spray1Num
lds R3,_Spray1Num+1
sts _SSpray1Num+1,R3
sts _SSpray1Num,R2
sts _SSpray1Num+2+1,R5
sts _SSpray1Num+2,R4
.dbline 193
; CPump1Cyc = tPump1Cyc * 1000-370;//修正0.37ms
ldd R18,y+1
clr R19
ldi R16,1000
ldi R17,3
rcall empy16s
movw R24,R16
subi R24,114
sbci R25,1
sts _CPump1Cyc+1,R25
sts _CPump1Cyc,R24
.dbline 194
; CPump1CycH = (CPump1Cyc >> 8);
movw R2,R24
mov R2,R3
clr R3
sts _CPump1CycH+1,R3
sts _CPump1CycH,R2
.dbline 195
; CSpray1On = (unsigned int)(tSpray1On * 100 );
ldi R24,100
ldd R0,y+2
mul R24,R0
sts _CSpray1On+1,R1
sts _CSpray1On,R0
.dbline 196
; CSpray1Cyc = (unsigned long )tSpray1Cyc * 1000 ;
ldd R2,y+3
ldd R3,y+4
clr R4
clr R5
ldi R20,232
ldi R21,3
ldi R22,0
ldi R23,0
st -y,R5
st -y,R4
st -y,R3
st -y,R2
movw R16,R20
movw R18,R22
rcall empy32u
sts _CSpray1Cyc+1,R17
sts _CSpray1Cyc,R16
sts _CSpray1Cyc+2+1,R19
sts _CSpray1Cyc+2,R18
.dbline 197
; CPump1On = tPump1On * 1000;
mov R18,R10
clr R19
ldi R16,1000
ldi R17,3
rcall empy16s
sts _CPump1On+1,R17
sts _CPump1On,R16
.dbline 198
; CPump1OnH = (CPump1On >> 8);
movw R2,R16
mov R2,R3
clr R3
sts _CPump1OnH+1,R3
sts _CPump1OnH,R2
.dbline 200
;
; Spray2Num = (int)spray2NumL + ((int)spray2NumH << 8);
mov R2,R14
clr R3
mov R3,R2
clr R2
mov R4,R12
clr R5
add R4,R2
adc R5,R3
movw R2,R4
clr R4
sbrc R3,7
com R4
clr R5
sbrc R4,7
com R5
sts _Spray2Num+1,R3
sts _Spray2Num,R2
sts _Spray2Num+2+1,R5
sts _Spray2Num+2,R4
.dbline 201
; Pump2Num = Spray2Num;
sts _Pump2Num+1,R3
sts _Pump2Num,R2
sts _Pump2Num+2+1,R5
sts _Pump2Num+2,R4
.dbline 202
; PPump2Num = Pump2Num;
lds R4,_Pump2Num+2
lds R5,_Pump2Num+2+1
lds R2,_Pump2Num
lds R3,_Pump2Num+1
sts _PPump2Num+1,R3
sts _PPump2Num,R2
sts _PPump2Num+2+1,R5
sts _PPump2Num+2,R4
.dbline 203
; SSpray2Num = Spray2Num;
lds R4,_Spray2Num+2
lds R5,_Spray2Num+2+1
lds R2,_Spray2Num
lds R3,_Spray2Num+1
sts _SSpray2Num+1,R3
sts _SSpray2Num,R2
sts _SSpray2Num+2+1,R5
sts _SSpray2Num+2,R4
.dbline 215
; //Pump2Num = Pump1Num;
; //CPump2Cyc = tPump2Cyc * 1000 -350;
; //CPump2Cyc = CPump1Cyc;
; //CPump2CycH = (CPump2Cyc >> 8);
; //CPump2CycH =CPump1CycH ;
; //CSpray2On = (unsigned int)(tSpray2On * 100 );
; //CSpray2Cyc = (unsigned long )tSpray2Cyc * 1000 ;
; //CPump2On = tPump2On * 1000 -200;
; //CPump2On = CPump1On;
; //CPump2OnH = (CPump2On >> 8);
; //CPump2OnH = CPump1OnH;
; HighByte1 = (unsigned char )(CSpray1Cyc >> 16);
lds R4,_CSpray1Cyc+2
lds R5,_CSpray1Cyc+2+1
lds R2,_CSpray1Cyc
lds R3,_CSpray1Cyc+1
movw R2,R4
clr R4
clr R5
sts _HighByte1,R2
.dbline 216
; HighByte2 = (unsigned char )(CSpray2Cyc >> 16);
lds R4,_CSpray2Cyc+2
lds R5,_CSpray2Cyc+2+1
lds R2,_CSpray2Cyc
lds R3,_CSpray2Cyc+1
movw R2,R4
clr R4
clr R5
sts _HighByte2,R2
.dbline 219
;
;
; CLI(); //禁止中断,保证以下发送的两字节连续
cli
.dbline 220
; putchar(REVSUCCEED); //回传接收成功标志
ldi R16,252
rcall _putchar
.dbline 221
; putchar(REVSUCCEED); //回传接收成功标志
ldi R16,252
rcall _putchar
.dbline 223
;
; if(IisOn)
ldd R0,y+0
tst R0
breq L50
X21:
.dbline 224
; SEI();
sei
L50:
.dbline 225
; }
L47:
.dbline 226
; FlashRxBuf();
rcall _FlashRxBuf
.dbline -2
L43:
.dbline 0 ; func end
adiw R28,7
rjmp pop_xgsetF0FC
.dbsym r spray2NumH 14 c
.dbsym r spray2NumL 12 c
.dbsym l spray1NumH 6 c
.dbsym l spray1NumL 5 c
.dbsym r tPump1On 10 c
.dbsym l tSpray1Cyc 3 i
.dbsym l tSpray1On 2 c
.dbsym l tPump1Cyc 1 c
.dbsym l IisOn 0 c
.dbend
.dbfile C:\DOCUME~1\Administrator\桌面\程序\油泵油嘴实验台\可用\油泵油~2\timer1.c
.dbfunc e timer0_init _timer0_init fV
.even
_timer0_init::
.dbline -1
.dbline 12
; #include <iom88v.h>
; #include <macros.h>
; #include <uart.h>
; #include <timer1.h>
;
;
; //TIMER0 initialize - prescale:8
; // WGM: Normal
; // desired value: 1Hz
; // actual value: 1953.125Hz (99.9%)
; void timer0_init(void)
; {
.dbline 13
; TCCR0B = 0x00; //stop
clr R2
out 0x25,R2
.dbline 14
; TCNT0 = 0x00; //set count
out 0x26,R2
.dbline 15
; TCCR0A = 0x00;
out 0x24,R2
.dbline 16
; TCCR0B = 0x02; //start timer
ldi R24,2
out 0x25,R24
.dbline 17
; OCR0B = 0x60;
ldi R24,96
out 0x28,R24
.dbline 18
; OCR0A = 0x03;
ldi R24,3
out 0x27,R24
.dbline -2
L52:
.dbline 0 ; func end
ret
.dbend
.dbfunc e timer1_init _timer1_init fV
.even
_timer1_init::
.dbline -1
.dbline 26
; }
;
; //TIMER1 initialize - prescale:8
; // WGM: 0) Normal, TOP=0xFFFF
; // desired value: 1MHz
; // actual value: Out of range
; void timer1_init(void)
; {
.dbline 27
; TCCR1B = 0x00; //stop
clr R2
sts 129,R2
.dbline 28
; TCNT1H = 0x00 /*INVALID SETTING*/; //setup
sts 133,R2
.dbline 29
; TCNT1L = 0x00 /*INVALID SETTING*/;
sts 132,R2
.dbline 30
; OCR1AH = 0x00 /*INVALID SETTING*/;
sts 137,R2
.dbline 31
; OCR1AL = 0x20 /*INVALID SETTING*/;
ldi R24,32
sts 136,R24
.dbline 32
; OCR1BH = 0x02 /*INVALID SETTING*/;
ldi R24,2
sts 139,R24
.dbline 33
; OCR1BL = 0xFF /*INVALID SETTING*/;
ldi R24,255
sts 138,R24
.dbline 34
; ICR1H = 0x00 /*INVALID SETTING*/;
sts 135,R2
.dbline 35
; ICR1L = 0x00 /*INVALID SETTING*/;
sts 134,R2
.dbline 36
; TCCR1A = 0x00;
sts 128,R2
.dbline 37
; TCCR1B = 0x02; //start Timer
ldi R24,2
sts 129,R24
.dbline -2
L53:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 22
rjmp _timer1_compa_isr
.area text(rom, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\程序\油泵油嘴实验台\可用\油泵油~2\timer1.c
.dbfunc e timer1_compa_isr _timer1_compa_isr fV
.even
_timer1_compa_isr::
st -y,R0
st -y,R1
st -y,R2
st -y,R3
st -y,R4
st -y,R5
st -y,R8
st -y,R9
st -y,R16
st -y,R17
st -y,R18
st -y,R19
st -y,R24
st -y,R25
st -y,R26
st -y,R27
st -y,R30
in R0,0x3f
st -y,R0
st -y,R10
st -y,R11
.dbline -1
.dbline 115
; }
; /*#pragma interrupt_handler timer0_compb_isr:iv_TIM0_COMPA
; void timer0_compb_isr(void) ///wy修改
; {
; if(Pump1Flag == 1)
; {
; if(Cyc1H== 0)
; {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -