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

📄 timer2.s

📁 使用Atmel88芯片实现RS485通讯,Modbus通讯协议.在IVR_AVR环境中编译,文件完整.
💻 S
字号:
	.module timer2.c
	.area text(rom, con, rel)
	.dbfile D:\ICCTES~1\1128\timer2.c
	.dbfunc e timer2_init _timer2_init fV
	.even
_timer2_init::
	.dbline -1
	.dbline 17
; // timer2
; #include <iom48v.h>
; #include <macros.h>
; #include "main.h"
; #include "modbus.h"
; #include "timer2.h"
; 
; volatile TIMEBASESTRCUT timeBase;
; volatile LEDCONTROL ledControl;
; //uchar var_a,var_b; 
; 
; //TIMER2 initialize - prescale:64
; // WGM: Normal
; // desired value: 1mSec
; // actual value:  1.000mSec (0.0%)
; void timer2_init(void)
; {
	.dbline 18
;  TCCR2B = 0x00; //stop
	clr R2
	sts 177,R2
	.dbline 19
;  ASSR  = 0x00; //set async mode
	sts 182,R2
	.dbline 20
;  TCNT2 = 0x83; //setup
	ldi R24,131
	sts 178,R24
	.dbline 21
;  OCR2A = 0x7D;
	ldi R24,125
	sts 179,R24
	.dbline 22
;  OCR2B = 0x00;
	sts 180,R2
	.dbline 23
;  TCCR2A = 0x00; 
	sts 176,R2
	.dbline 24
;  TCCR2B = 0x04; //start
	ldi R24,4
	sts 177,R24
	.dbline -2
L5:
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile D:\ICCTES~1\1128\timer2.c
L7:
	.blkb 1
L8:
	.blkb 1
L9:
	.blkb 2
	.area text(rom, con, rel)
	.dbfile D:\ICCTES~1\1128\timer2.c
	.dbfunc e time_mission _time_mission fV
	.dbsym s cnt500ms L9 i
	.dbsym s varcou L8 c
	.dbsym s Cnt100ms L7 c
	.even
_time_mission::
	.dbline -1
	.dbline 29
; }
; 
; // timebase module.
; void time_mission (void)       
; {
	.dbline 33
; 	static uchar Cnt100ms;
; 	static uchar varcou;
; 	static uint cnt500ms;
;  	timeBase.bits.b1ms = 0;
	lds R24,_timeBase
	andi R24,254
	sts _timeBase,R24
	.dbline 34
; 	timeBase.bits.b10ms = 0;
	lds R24,_timeBase
	andi R24,251
	sts _timeBase,R24
	.dbline 36
;     
; 	if(timeBase.bits.bt1ms) 
	lds R24,_timeBase
	lsr R24
	andi R24,1
	brne X0
	rjmp L10
X0:
	.dbline 37
; 	{ 
	.dbline 42
; 	//--------------------
; 	//    PORTC ^= 0x02;
; 	//      subled();	
; 	//-----------------------
; 		timeBase.bits.bt1ms = 0; 
	lds R24,_timeBase
	andi R24,253
	sts _timeBase,R24
	.dbline 43
; 		timeBase.bits.b1ms = 1; 
	lds R24,_timeBase
	ori R24,1
	sts _timeBase,R24
	.dbline 44
; 		if(receTimeOut>0) 
	clr R2
	lds R3,_receTimeOut
	cp R2,R3
	brsh L12
	.dbline 45
; 		{
	.dbline 46
; 			receTimeOut--;
	mov R24,R3
	subi R24,1
	sts _receTimeOut,R24
	.dbline 47
; 			if(receTimeOut==0 && receCount>0)
	tst R24
	brne L14
	lds R3,_receCount
	cp R2,R3
	brsh L14
	.dbline 48
; 			{
	.dbline 49
; 				receCount = 0;
	sts _receCount,R2
	.dbline 50
; 				checkoutError = 0;
	sts _checkoutError,R2
	.dbline 51
; 			} 
L14:
	.dbline 52
; 		} //if(receTimeOut>0) 
L12:
	.dbline 54
; 		
; 		varcou++;
	lds R24,L8
	subi R24,255    ; addi 1
	sts L8,R24
	.dbline 55
;   		if(varcou>=5)
	cpi R24,5
	brlo L16
	.dbline 56
;     	{                                              
	.dbline 58
;             
; 			ledControl.bits.refurbish = 1;  
	lds R24,_ledControl
	ori R24,2
	sts _ledControl,R24
	.dbline 59
;     		varcou = 0;                     
	clr R2
	sts L8,R2
	.dbline 60
;     	}                                   
L16:
	.dbline 62
; 	
; 	    cnt500ms++;
	lds R24,L9
	lds R25,L9+1
	adiw R24,1
	sts L9+1,R25
	sts L9,R24
	.dbline 63
; 	    if(cnt500ms>=200)
	cpi R24,200
	ldi R30,0
	cpc R25,R30
	brlo L18
	.dbline 64
; 	    {	 
	.dbline 65
; 		    cnt500ms = 0;
	clr R2
	clr R3
	sts L9+1,R3
	sts L9,R2
	.dbline 66
; 		    ledControl.bits.once128ms = 1;
	lds R24,_ledControl
	ori R24,1
	sts _ledControl,R24
	.dbline 67
; 	    }
L18:
	.dbline 68
L10:
	.dbline -2
L6:
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile D:\ICCTES~1\1128\timer2.c
_ledControl::
	.blkb 2
	.dbstruct 0 1 .4
	.dbfield 0 once128ms F[0:1]
	.dbfield 0 refurbish F[1:1]
	.dbend
	.dbunion 0 2 .3
	.dbfield 0 bits S[.4]
	.dbfield 0 allbits i
	.dbend
	.dbsym e ledControl _ledControl S[.3]
_timeBase::
	.blkb 2
	.dbstruct 0 1 .2
	.dbfield 0 b1ms F[0:1]
	.dbfield 0 bt1ms F[1:1]
	.dbfield 0 b10ms F[2:1]
	.dbfield 0 bt10ms F[3:1]
	.dbend
	.dbunion 0 2 .1
	.dbfield 0 bits S[.2]
	.dbfield 0 allbits i
	.dbend
	.dbsym e timeBase _timeBase S[.1]

⌨️ 快捷键说明

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