⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer1.s

📁 一个6缸发动机的ECU控制程序
💻 S
字号:
	.module timer1.c
	.area text(rom, con, rel)
	.dbfile F:\程序\avr\timer1.c
	.area data(ram, con, rel)
	.dbfile F:\程序\avr\timer1.c
_SprayNum::
	.blkb 2
	.area idata
	.word 6000
	.area data(ram, con, rel)
	.dbfile F:\程序\avr\timer1.c
	.dbfile F:\程序\avr\timer1.h
	.dbsym e SprayNum _SprayNum I
_CSprayCyc::
	.blkb 2
	.area idata
	.word 6250
	.area data(ram, con, rel)
	.dbfile F:\程序\avr\timer1.h
	.dbsym e CSprayCyc _CSprayCyc i
_CSprayOn::
	.blkb 2
	.area idata
	.word 250
	.area data(ram, con, rel)
	.dbfile F:\程序\avr\timer1.h
	.dbsym e CSprayOn _CSprayOn i
_CPivDelay::
	.blkb 2
	.area idata
	.word 125
	.area data(ram, con, rel)
	.dbfile F:\程序\avr\timer1.h
	.dbsym e CPivDelay _CPivDelay i
_T1OveForPump::
	.blkb 1
	.area idata
	.byte 28
	.area data(ram, con, rel)
	.dbfile F:\程序\avr\timer1.h
	.dbsym e T1OveForPump _T1OveForPump c
_T1OveCnt::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile F:\程序\avr\timer1.h
	.dbsym e T1OveCnt _T1OveCnt c
_ActFlag::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile F:\程序\avr\timer1.h
	.dbsym e ActFlag _ActFlag c
	.area text(rom, con, rel)
	.dbfile F:\程序\avr\timer1.h
	.dbfile F:\程序\avr\timer1.c
	.dbfunc e timer1_init _timer1_init fV
	.even
_timer1_init::
	.dbline -1
	.dbline 12
; #include <iom88v.h>
; #include <macros.h>
; #include <uart.h>
; #include <timer1.h>
; 
; 
; //TIMER1 initialize - prescale:64
; // WGM: 0) Normal, TOP=0xFFFF
; // desired value: 1Hz
; // actual value: Out of range
; void timer1_init(void)
; {
	.dbline 13
;  TCCR1B = 0x00; //stop
	clr R2
	sts 129,R2
	.dbline 14
;  TCNT1H = 0x00 /*INVALID SETTING*/; //setup
	sts 133,R2
	.dbline 15
;  TCNT1L = 0x00 /*INVALID SETTING*/;
	sts 132,R2
	.dbline 16
;  OCR1AH = 0x00 /*INVALID SETTING*/;
	sts 137,R2
	.dbline 17
;  OCR1AL = 0x30 /*INVALID SETTING*/;
	ldi R24,48
	sts 136,R24
	.dbline 18
;  OCR1BH = 0x02 /*INVALID SETTING*/;
	ldi R24,2
	sts 139,R24
	.dbline 19
;  OCR1BL = 0xFF /*INVALID SETTING*/;
	ldi R24,255
	sts 138,R24
	.dbline 20
;  ICR1H  = 0x00 /*INVALID SETTING*/;
	sts 135,R2
	.dbline 21
;  ICR1L  = 0x00 /*INVALID SETTING*/;
	sts 134,R2
	.dbline 22
;  TCCR1A = 0x00;
	sts 128,R2
	.dbline 23
;  TCCR1B = 0x03; //start Timer
	ldi R24,3
	sts 129,R24
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 22
	rjmp _timer1_compa_isr
	.area text(rom, con, rel)
	.dbfile F:\程序\avr\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,R6
	st -y,R7
	st -y,R8
	st -y,R9
	st -y,R16
	st -y,R17
	st -y,R18
	st -y,R19
	st -y,R20
	st -y,R21
	st -y,R24
	st -y,R25
	st -y,R26
	st -y,R27
	st -y,R30
	st -y,R31
	in R0,0x3f
	st -y,R0
	st -y,R20
	st -y,R21
	.dbline -1
	.dbline 29
; }
; 
; 
; #pragma interrupt_handler timer1_compa_isr:iv_TIM1_COMPA
; void timer1_compa_isr(void)
; {
	.dbline 31
;  //compare occured TCNT1=OCR1A
;  switch(ActFlag)
	lds R20,_ActFlag
	clr R21
	cpi R20,0
	cpc R20,R21
	breq L6
X0:
	cpi R20,1
	ldi R30,0
	cpc R21,R30
	breq L9
X1:
	cpi R20,2
	ldi R30,0
	cpc R21,R30
	brne X9
	rjmp L12
X9:
X2:
	rjmp L4
L6:
	.dbline 34
;  {
;    case 0:
;      {
	.dbline 35
; 	   if(SprayNum > 0)
	clr R2
	clr R3
	lds R4,_SprayNum
	lds R5,_SprayNum+1
	cp R2,R4
	cpc R3,R5
	brge L7
X3:
	.dbline 37
; 	     //喷油器控制引脚置高
; 		 PORTB = PORTB |(1<<PB2);
	sbi 0x5,2
L7:
	.dbline 39
; 		 
; 	   OCR1B = (OCR1A + CSprayOn);    //喷油器关定时
	lds R2,_CSprayOn
	lds R3,_CSprayOn+1
	lds R4,136
	lds R5,136+1
	add R4,R2
	adc R5,R3
	sts 138+1,R5
	sts 138,R4
	.dbline 40
; 	   OCR1A = (OCR1A + CPivDelay);          //piv开启定时
	lds R2,_CPivDelay
	lds R3,_CPivDelay+1
	lds R4,136
	lds R5,136+1
	add R4,R2
	adc R5,R3
	sts 136+1,R5
	sts 136,R4
	.dbline 43
; //	   OCR1B &= 0xFFFF;           
; //	   OCR1B &= 0xFFFF;
;        ActFlag = (++ActFlag) % 3;   //转换到下一动作
	lds R24,_ActFlag
	subi R24,255    ; addi 1
	mov R2,R24
	sts _ActFlag,R2
	ldi R17,3
	mov R16,R24
	rcall mod8u
	sts _ActFlag,R16
	.dbline 44
;        break;
	rjmp L4
L9:
	.dbline 47
; 	 }
;    case 1:
;      {
	.dbline 48
; 	   if(SprayNum >0)
	clr R2
	clr R3
	lds R4,_SprayNum
	lds R5,_SprayNum+1
	cp R2,R4
	cpc R3,R5
	brge L10
X4:
	.dbline 50
; 	     //piv开
; 		 PORTB |=(1<<PB5);
	sbi 0x5,5
L10:
	.dbline 52
; 		 
; 	   OCR1A = OCR1A + CPIVON;             //piv关定时
	lds R24,136
	lds R25,136+1
	adiw R24,62
	sts 136+1,R25
	sts 136,R24
	.dbline 53
; 	   ActFlag = (++ActFlag) % 3;   //转换到下一动作
	lds R24,_ActFlag
	subi R24,255    ; addi 1
	mov R2,R24
	sts _ActFlag,R2
	ldi R17,3
	mov R16,R24
	rcall mod8u
	sts _ActFlag,R16
	.dbline 54
; 	   break;	 
	rjmp L4
L12:
	.dbline 57
; 	 }
;    case 2:
;      {
	.dbline 58
; 	   if(SprayNum > 0)
	clr R2
	clr R3
	lds R4,_SprayNum
	lds R5,_SprayNum+1
	cp R2,R4
	cpc R3,R5
	brge L13
X5:
	.dbline 60
; 	     //piv关
; 		 PORTB = PORTB & ~(1<<PB5);
	cbi 0x5,5
L13:
	.dbline 62
; 		 
; 	   OCR1A = OCR1A + CSprayCyc - CPivDelay - CPIVON;
	lds R2,_CSprayCyc
	lds R3,_CSprayCyc+1
	lds R24,136
	lds R25,136+1
	add R24,R2
	adc R25,R3
	lds R2,_CPivDelay
	lds R3,_CPivDelay+1
	sub R24,R2
	sbc R25,R3
	sbiw R24,62
	sts 136+1,R25
	sts 136,R24
	.dbline 63
; 	   SprayNum--;
	lds R24,_SprayNum
	lds R25,_SprayNum+1
	sbiw R24,1
	sts _SprayNum+1,R25
	sts _SprayNum,R24
	.dbline 65
; 	   
; 	   if(SprayNum < 0)
	cpi R24,0
	ldi R30,0
	cpc R25,R30
	brge L15
X6:
	.dbline 66
; 	     SprayNum = 0;
	clr R2
	clr R3
	sts _SprayNum+1,R3
	sts _SprayNum,R2
L15:
	.dbline 68
; 		 
; 	   ActFlag = (++ActFlag) % 3;   //转换到下一动作
	lds R20,_ActFlag
	subi R20,255    ; addi 1
	sts _ActFlag,R20
	ldi R17,3
	mov R16,R20
	rcall mod8u
	sts _ActFlag,R16
	.dbline 69
; 	   if(FrameHead0 > 0 && rx_counter0 == 0)
	ldi R24,0
	lds R2,_FrameHead0
	cp R24,R2
	brsh L4
X7:
	lds R2,_rx_counter0
	tst R2
	brne L4
X8:
	.dbline 70
; 	     putchar(IDLE);
	ldi R16,253
	rcall _putchar
	.dbline 71
; 	   break;	   
	.dbline 74
;      }	
;    default:
; 	   break;	  
L4:
	.dbline -2
L2:
	.dbline 0 ; func end
	ld R21,y+
	ld R20,y+
	ld R0,y+
	out 0x3f,R0
	ld R31,y+
	ld R30,y+
	ld R27,y+
	ld R26,y+
	ld R25,y+
	ld R24,y+
	ld R21,y+
	ld R20,y+
	ld R19,y+
	ld R18,y+
	ld R17,y+
	ld R16,y+
	ld R9,y+
	ld R8,y+
	ld R7,y+
	ld R6,y+
	ld R5,y+
	ld R4,y+
	ld R3,y+
	ld R2,y+
	ld R1,y+
	ld R0,y+
	reti
	.dbend
	.area vector(rom, abs)
	.org 24
	rjmp _timer1_compb_isr
	.area text(rom, con, rel)
	.dbfile F:\程序\avr\timer1.c
	.dbfunc e timer1_compb_isr _timer1_compb_isr fV
	.even
_timer1_compb_isr::
	st -y,R0
	in R0,0x3f
	st -y,R0
	.dbline -1
	.dbline 80
;  }
; }
; 
; #pragma interrupt_handler timer1_compb_isr:iv_TIM1_COMPB
; void timer1_compb_isr(void)
; {
	.dbline 83
;  //compare occured TCNT1=OCR1B
;  //喷油器控制引脚复位
;  PORTB = PORTB &~(1<<PB2);
	cbi 0x5,2
	.dbline -2
L19:
	.dbline 0 ; func end
	ld R0,y+
	out 0x3f,R0
	ld R0,y+
	reti
	.dbend
	.area vector(rom, abs)
	.org 26
	rjmp _timer1_ovf_isr
	.area text(rom, con, rel)
	.dbfile F:\程序\avr\timer1.c
	.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
	.even
_timer1_ovf_isr::
	st -y,R2
	st -y,R3
	st -y,R4
	st -y,R5
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 88
; }
; 
; #pragma interrupt_handler timer1_ovf_isr:iv_TIM1_OVF
; void timer1_ovf_isr(void)
; {
	.dbline 90
;  //TIMER1 has overflowed
;  T1OveCnt++;
	lds R24,_T1OveCnt
	subi R24,255    ; addi 1
	sts _T1OveCnt,R24
	.dbline 91
;  if(T1OveCnt > T1OveForPump)      //定时时间到
	lds R2,_T1OveForPump
	clr R3
	mov R4,R24
	clr R5
	cp R2,R4
	cpc R3,R5
	brge L21
X10:
	.dbline 92
;    {
	.dbline 94
;      //换能器控制引脚取反
; 	 PORTB = PORTB ^( 1<<PB3);
	ldi R24,8
	in R2,0x5
	eor R2,R24
	out 0x5,R2
	.dbline 95
; 	 T1OveCnt = 0;
	clr R2
	sts _T1OveCnt,R2
	.dbline 96
;    }
L21:
	.dbline -2
L20:
	.dbline 0 ; func end
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R5,y+
	ld R4,y+
	ld R3,y+
	ld R2,y+
	reti
	.dbend
	.area bss(ram, con, rel)
	.dbfile F:\程序\avr\timer1.c
_tx_counter0::
	.blkb 1
	.dbfile F:\程序\avr\uart.h
	.dbsym e tx_counter0 _tx_counter0 c
_tx_rd_index0::
	.blkb 1
	.dbsym e tx_rd_index0 _tx_rd_index0 c
_tx_wr_index0::
	.blkb 1
	.dbsym e tx_wr_index0 _tx_wr_index0 c
_tx_buffer0::
	.blkb 8
	.dbsym e tx_buffer0 _tx_buffer0 A[8:8]c
_FrameHead0::
	.blkb 1
	.dbsym e FrameHead0 _FrameHead0 c
_rx_error0::
	.blkb 1
	.dbsym e rx_error0 _rx_error0 c
_rx_counter0::
	.blkb 1
	.dbsym e rx_counter0 _rx_counter0 c
_rx_rd_index0::
	.blkb 1
	.dbsym e rx_rd_index0 _rx_rd_index0 c
_rx_buffer0::
	.blkb 8
	.dbsym e rx_buffer0 _rx_buffer0 A[8:8]c
; 
; }
; 
; 
; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -