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

📄 time_master.s

📁 用ICC编写的程序包括SPI
💻 S
字号:
	.module time_master.c
	.area text(rom, con, rel)
	.dbfile F:\IccAvr_Pro\time_master.c
	.dbfunc e timer0_init _timer0_init fV
	.even
_timer0_init::
	.dbline -1
	.dbline 12
; #include "time_master.h"
; 
; unsigned char timeflag;
; unsigned char dispflag;
; unsigned char disp_cnt;
; 
; //TIMER0 initialize - prescale:256
; // WGM: Normal
; // desired value: 5mSec
; // actual value:  4.965mSec (0.7%)
; void timer0_init(void)
; {
	.dbline 13
;  TCCR0 = 0x00; //stop
	clr R2
	out 0x33,R2
	.dbline 14
;  TCNT0 = 0x71; //set count
	ldi R24,113
	out 0x32,R24
	.dbline 15
;  OCR0  = 0x8F;  //set compare
	ldi R24,143
	out 0x3c,R24
	.dbline 16
;  TCCR0 = 0x04; //start timer
	ldi R24,4
	out 0x33,R24
	.dbline 17
;  timeflag=1;
	ldi R24,1
	sts _timeflag,R24
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 36
	jmp _timer0_ovf_isr
	.area text(rom, con, rel)
	.dbfile F:\IccAvr_Pro\time_master.c
	.dbfunc e timer0_ovf_isr _timer0_ovf_isr fV
	.even
_timer0_ovf_isr::
	st -y,R24
	in R24,0x3f
	st -y,R24
	.dbline -1
	.dbline 22
; }
; 
; #pragma interrupt_handler timer0_ovf_isr:10
; void timer0_ovf_isr(void)
; {
	.dbline 23
;  TCNT0 = 0x71; //reload counter value
	ldi R24,113
	out 0x32,R24
	.dbline 24
;  timeflag=1;
	ldi R24,1
	sts _timeflag,R24
	.dbline -2
L2:
	ld R24,y+
	out 0x3f,R24
	ld R24,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e timer2_init _timer2_init fV
	.even
_timer2_init::
	.dbline -1
	.dbline 32
; }
; 
; //TIMER2 initialize - prescale:256
; // WGM: Normal
; // desired value: 5mSec
; // actual value:  4.965mSec (0.7%)
; void timer2_init(void)
; {
	.dbline 33
;  TCCR2 = 0x00; //stop
	clr R2
	out 0x25,R2
	.dbline 34
;  ASSR  = 0x00; //set async mode
	out 0x22,R2
	.dbline 35
;  TCNT2 = 0x00; //setup
	out 0x24,R2
	.dbline 36
;  OCR2  = 0xD7;
	ldi R24,215
	out 0x23,R24
	.dbline 37
;  TCCR2 = 0x07; //start
	ldi R24,7
	out 0x25,R24
	.dbline 38
;  dispflag=0;
	sts _dispflag,R2
	.dbline 39
;  disp_cnt=0;
	sts _disp_cnt,R2
	.dbline -2
L3:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 16
	jmp _timer2_ovf_isr
	.area text(rom, con, rel)
	.dbfile F:\IccAvr_Pro\time_master.c
	.dbfunc e timer2_ovf_isr _timer2_ovf_isr fV
	.even
_timer2_ovf_isr::
	st -y,R2
	st -y,R3
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 44
	.dbline 45
	clr R2
	out 0x24,R2
	.dbline 46
	lds R2,_disp_cnt
	clr R3
	mov R24,R2
	subi R24,255    ; addi 1
	sts _disp_cnt,R24
	ldi R24,100
	cp R24,R2
	brsh L5
	.dbline 47
	.dbline 48
	clr R2
	sts _disp_cnt,R2
	.dbline 49
	ldi R24,1
	sts _dispflag,R24
	.dbline 50
L5:
	.dbline -2
L4:
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R3,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.area bss(ram, con, rel)
	.dbfile F:\IccAvr_Pro\time_master.c
_disp_cnt::
	.blkb 1
	.dbsym e disp_cnt _disp_cnt c
_dispflag::
	.blkb 1
	.dbsym e dispflag _dispflag c
_timeflag::
	.blkb 1
	.dbsym e timeflag _timeflag c

⌨️ 快捷键说明

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