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

📄 main.s

📁 ATMEGA128的SEG7驱动程序
💻 S
字号:
	.module main.c
	.area data(ram, con, rel)
_countnum::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile D:\avrvi\AVRVi_m128_Starter_Kit\Seg7\source\main.c
	.dbsym e countnum _countnum i
	.area text(rom, con, rel)
	.dbfile D:\avrvi\AVRVi_m128_Starter_Kit\Seg7\source\main.c
	.dbfunc e timer1_init _timer1_init fV
	.even
_timer1_init::
	.dbline -1
	.dbline 14
; /************************************************
; 文件:main.c
; 用途:
; 注意:内部8M晶振
; 创建:2008.4.1
; 修改:2008.4.1
; Copy Right  (c)  www.avrvi.com  AVR与虚拟仪器
; ************************************************/
; 
; #include "config.h"
; volatile unsigned int countnum=0; 
; 
; void timer1_init(void)
; {
	.dbline 15
;  TCCR1B = 0x00; //stop
	clr R2
	out 0x2e,R2
	.dbline 16
;  TCNT1H = 0x8F; //setup
	ldi R24,143
	out 0x2d,R24
	.dbline 17
;  TCNT1L = 0x81;
	ldi R24,129
	out 0x2c,R24
	.dbline 18
;  OCR1AH = 0x70;
	ldi R24,112
	out 0x2b,R24
	.dbline 19
;  OCR1AL = 0x7F;
	ldi R24,127
	out 0x2a,R24
	.dbline 20
;  OCR1BH = 0x70;
	ldi R24,112
	out 0x29,R24
	.dbline 21
;  OCR1BL = 0x7F;
	ldi R24,127
	out 0x28,R24
	.dbline 22
;  OCR1CH = 0x70;
	ldi R24,112
	sts 121,R24
	.dbline 23
;  OCR1CL = 0x7F;
	ldi R24,127
	sts 120,R24
	.dbline 24
;  ICR1H  = 0x70;
	ldi R24,112
	out 0x27,R24
	.dbline 25
;  ICR1L  = 0x7F;
	ldi R24,127
	out 0x26,R24
	.dbline 26
;  TCCR1A = 0x00;
	out 0x2f,R2
	.dbline 27
;  TCCR1B = 0x04; //start Timer
	ldi R24,4
	out 0x2e,R24
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 56
	jmp _timer1_ovf_isr
	.area text(rom, con, rel)
	.dbfile D:\avrvi\AVRVi_m128_Starter_Kit\Seg7\source\main.c
	.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
	.even
_timer1_ovf_isr::
	st -y,R2
	st -y,R3
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 32
	.dbline 33
	ldi R24,143
	out 0x2d,R24
	.dbline 34
	ldi R24,129
	out 0x2c,R24
	.dbline 35
	lds R24,_countnum
	lds R25,_countnum+1
	adiw R24,1
	sts _countnum+1,R25
	sts _countnum,R24
	.dbline 36
	ldi R24,9999
	ldi R25,39
	lds R2,_countnum
	lds R3,_countnum+1
	cp R24,R2
	cpc R25,R3
	brsh L3
	.dbline 36
	clr R2
	clr R3
	sts _countnum+1,R3
	sts _countnum,R2
L3:
	.dbline -2
L2:
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R3,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 40
; }
; 
; #pragma interrupt_handler timer1_ovf_isr:15
; void timer1_ovf_isr(void)
; {
;  TCNT1H = 0x8F; //reload counter high value
;  TCNT1L = 0x81; //reload counter low value
;  countnum++;
;  if(countnum>9999) countnum=0;
; }
; 
; void init_devices(void)
; {
	.dbline 41
;  CLI(); //disable all interrupts
	cli
	.dbline 42
;  timer1_init();
	xcall _timer1_init
	.dbline 43
;  TIMSK = 0x04; //timer interrupt sources
	ldi R24,4
	out 0x37,R24
	.dbline 44
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
L5:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 48
; }
; 
; void main(void)
; {
	.dbline 49
;  init_devices(); 
	xcall _init_devices
	.dbline 50
;  HC_595_init();
	xcall _HC_595_init
	xjmp L8
L7:
	.dbline 52
	.dbline 53
	lds R16,_countnum
	lds R17,_countnum+1
	xcall _Seg7_Led_display
	.dbline 55
L8:
	.dbline 51
	xjmp L7
X0:
	.dbline -2
L6:
	.dbline 0 ; func end
	ret
	.dbend

⌨️ 快捷键说明

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