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

📄 common.s

📁 微程序控制器采用ATMEL AVR MEGA162
💻 S
字号:
	.module common.c
	.area text(rom, con, rel)
	.dbfile F:\mydoc\avrproject\icc\big162\gpseep\common.c
	.dbfunc e delay _delay fV
;              a -> R16
	.even
_delay::
	.dbline -1
	.dbline 3
; #include "common.h"
; void delay(BYTE a)
; {
	xjmp L3
L2:
	.dbline 5
	dec R16
L3:
	.dbline 4
;     while(a)
	tst R16
	brne L2
	.dbline 6
;     a--;
;     asm("nop");
	nop
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbsym r a 16 c
	.dbend
	.dbfunc e DelayM _DelayM fV
;              a -> R20
;              b -> R22,R23
;              c -> R16
	.even
_DelayM::
	xcall push_gset2
	.dbline -1
	.dbline 11
; }
; 
; 
; void DelayM(BYTE c)
; {
	.dbline 14
;     unsigned char a;
; 	unsigned int b;
;     for (a = c; a; a--)
	mov R20,R16
	xjmp L9
L6:
	.dbline 15
;     for (b = 64911; b; b++)
	ldi R22,64911
	ldi R23,253
	xjmp L13
L10:
	.dbline 16
L11:
	.dbline 15
	subi R22,255  ; offset = 1
	sbci R23,255
L13:
	.dbline 15
	cpi R22,0
	cpc R22,R23
	brne L10
X0:
L7:
	.dbline 14
	dec R20
L9:
	.dbline 14
	tst R20
	brne L6
	.dbline -2
L5:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r a 20 c
	.dbsym r b 22 i
	.dbsym r c 16 c
	.dbend
	.dbfunc e DelayMORE _DelayMORE fV
;              a -> R20
;              b -> R22,R23
;              c -> R16
	.even
_DelayMORE::
	xcall push_gset2
	.dbline -1
	.dbline 20
;     ;
; }
; 
; void DelayMORE(BYTE c)
; {
	.dbline 23
;     unsigned char a;
; 	unsigned int b;
;     for (a = c; a; a--)
	mov R20,R16
	xjmp L18
L15:
	.dbline 24
;     for (b = 1; b; b++)
	ldi R22,1
	ldi R23,0
	xjmp L22
L19:
	.dbline 25
L20:
	.dbline 24
	subi R22,255  ; offset = 1
	sbci R23,255
L22:
	.dbline 24
	cpi R22,0
	cpc R22,R23
	brne L19
X1:
L16:
	.dbline 23
	dec R20
L18:
	.dbline 23
	tst R20
	brne L15
	.dbline -2
L14:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r a 20 c
	.dbsym r b 22 i
	.dbsym r c 16 c
	.dbend
	.area data(ram, con, rel)
	.dbfile F:\mydoc\avrproject\icc\big162\gpseep\common.c
_timerCounter::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile F:\mydoc\avrproject\icc\big162\gpseep\common.c
	.dbsym e timerCounter _timerCounter c
_timerCounter1::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile F:\mydoc\avrproject\icc\big162\gpseep\common.c
	.dbsym e timerCounter1 _timerCounter1 c
_timerCounter2::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile F:\mydoc\avrproject\icc\big162\gpseep\common.c
	.dbsym e timerCounter2 _timerCounter2 c
	.area text(rom, con, rel)
	.dbfile F:\mydoc\avrproject\icc\big162\gpseep\common.c
	.dbfunc e initTimer _initTimer fV
	.even
_initTimer::
	.dbline -1
	.dbline 36
;     ;
; }
; 
; 
; BYTE volatile timerCounter = 0;
; BYTE volatile timerCounter1 = 0;
; BYTE volatile timerCounter2 = 0;
; BYTE timepoint;
; BYTE timepoint1;
; BYTE timepoint2;
; void initTimer()
; {
	.dbline 37
;  	TCCR0 = 5;  // timer0 prescale 1/1024 (7)
	ldi R24,5
	out 0x33,R24
	.dbline 38
;   	timepoint=255;
	ldi R24,255
	sts _timepoint,R24
	.dbline -2
L23:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 68
	jmp _SIG_OVERFLOW0
	.area text(rom, con, rel)
	.dbfile F:\mydoc\avrproject\icc\big162\gpseep\common.c
	.dbfunc e SIG_OVERFLOW0 _SIG_OVERFLOW0 fV
	.even
_SIG_OVERFLOW0::
	st -y,R2
	st -y,R3
	st -y,R4
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 43
	.dbline 44
	lds R2,_timerCounter
	clr R3
	mov R24,R2
	subi R24,255    ; addi 1
	sts _timerCounter,R24
	lds R4,_timepoint
	cp R4,R2
	brsh L25
	.dbline 44
	.dbline 45
	ldi R24,32
	in R2,0x12
	eor R2,R24
	out 0x12,R2
	.dbline 46
	ldi R24,64
	in R2,0x12
	eor R2,R24
	out 0x12,R2
	.dbline 47
	ldi R24,4
	in R2,0x1b
	eor R2,R24
	out 0x1b,R2
	.dbline 48
	clr R2
	sts _timerCounter,R2
	.dbline 49
L25:
	.dbline -2
L24:
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R4,y+
	ld R3,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e initTimer2 _initTimer2 fV
	.even
_initTimer2::
	.dbline -1
	.dbline 53
; }
; #pragma interrupt_handler SIG_OVERFLOW0:18
; 
; void SIG_OVERFLOW0(void)//timer0
; {
;   	if(timerCounter++ > timepoint){
; 		PORTD ^= BIT(STA);
;         PORTD ^= BIT(STC);
;         PORTA ^= BIT(SPEAKER);//alarm
; 		timerCounter = 0;
; 	}
;     
; }
; void initTimer2()
; {
	.dbline 54
;  TCCR2= 5; //prescale 1/1024
	ldi R24,5
	out 0x27,R24
	.dbline 56
; 
;  timerCounter2 = 20;
	ldi R24,20
	sts _timerCounter2,R24
	.dbline -2
L27:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 44
	jmp _timer2_ovf_isr
	.area text(rom, con, rel)
	.dbfile F:\mydoc\avrproject\icc\big162\gpseep\common.c
	.dbfunc e timer2_ovf_isr _timer2_ovf_isr fV
	.even
_timer2_ovf_isr::
	st -y,R2
	st -y,R3
	st -y,R4
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 60
	.dbline 61
	lds R2,_timerCounter2
	clr R3
	mov R24,R2
	subi R24,255    ; addi 1
	sts _timerCounter2,R24
	lds R4,_timepoint2
	cp R4,R2
	brsh L29
	.dbline 61
	.dbline 63
	in R24,0x39
	andi R24,251
	out 0x39,R24
	.dbline 64
	clr R2
	sts _timerCounter2,R2
	.dbline 65
	sbi 0x1b,2
	.dbline 66
L29:
	.dbline -2
L28:
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R4,y+
	ld R3,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e timer1_init _timer1_init fV
	.even
_timer1_init::
	.dbline -1
	.dbline 70
; }
; #pragma interrupt_handler timer2_ovf_isr:12
; void timer2_ovf_isr(void)//timer2
; {
;   	if(timerCounter2++ > timepoint2){
; 		
; 		cbi( TIMSK, TOIE2 );
;         timerCounter2 = 0;
;         PORTA |= BIT(SPEAKER);
; 	}
; }
; 
; void timer1_init(void)
; {
	.dbline 71
;  TCCR1B= 0x00; //stop18s
	clr R2
	out 0x2e,R2
	.dbline 72
;  TCCR1A= 0x00;
	out 0x2f,R2
	.dbline 73
;  TCCR1B= 0x05; //start Timer
	ldi R24,5
	out 0x2e,R24
	.dbline 74
;  timepoint1=3;
	ldi R24,3
	sts _timepoint1,R24
	.dbline -2
L31:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 60
	jmp _timer1_ovf_isr
	.area text(rom, con, rel)
	.dbfile F:\mydoc\avrproject\icc\big162\gpseep\common.c
	.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
	.even
_timer1_ovf_isr::
	xcall push_lset
	.dbline -1
	.dbline 78
	.dbline 82
	lds R2,_timerCounter1
	clr R3
	mov R24,R2
	subi R24,255    ; addi 1
	sts _timerCounter1,R24
	lds R4,_timepoint1
	cp R4,R2
	brsh L33
	.dbline 82
	.dbline 83
	xcall _watchdog_init
	.dbline 84
L33:
	.dbline -2
L32:
	xcall pop_lset
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e watchdog_init _watchdog_init fV
	.even
_watchdog_init::
	.dbline -1
	.dbline 91
; }
; #pragma interrupt_handler timer1_ovf_isr:16
; void timer1_ovf_isr(void)
; {
; 
;  //TCNT1H= 0x02; //reload counter high value
;  //TCNT1L= 0xE1; //reload counter low value
;     if(timerCounter1++ > timepoint1){
;     	watchdog_init();//reset
;     }
;     //PORTA ^= BIT(SPEAKER);
; }
; 
; 
; 
; void watchdog_init() 
; { 
	.dbline 92
;     WDR();
	wdr
	.dbline 93
;     WDTCR=0x18;
	ldi R24,24
	out 0x21,R24
	.dbline 94
;     WDTCR=0x08;//最快复位8,最慢f
	ldi R24,8
	out 0x21,R24
	.dbline -2
L35:
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile F:\mydoc\avrproject\icc\big162\gpseep\common.c
_timepoint1::
	.blkb 1
	.dbsym e timepoint1 _timepoint1 c
_timepoint2::
	.blkb 1
	.dbsym e timepoint2 _timepoint2 c
_timepoint::
	.blkb 1
	.dbsym e timepoint _timepoint c

⌨️ 快捷键说明

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