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

📄 c_ledpmd.s

📁 是一款开发板的外围电路试验程序(附有原理图)
💻 S
字号:
	.module C_LEDPMD.C
	.area data(ram, con, rel)
_LM_Data::
	.blkb 2
	.area idata
	.word 1
	.area data(ram, con, rel)
	.dbfile F:\工程文件\AVR光盘\例程\m16\LED跑马灯\C_LEDPMD.C
	.dbsym e LM_Data _LM_Data i
	.area text(rom, con, rel)
	.dbfile F:\工程文件\AVR光盘\例程\m16\LED跑马灯\C_LEDPMD.C
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 15
; //ICC-AVR application builder : 2007-3-14 9:32:42
; // Target : M16
; // Crystal: 7.3728Mhz
; // Designed by solo       转载请注明
; // http://www.ourembed.com     
; // qq:15537031 phone:13879805760
; //该程序使用了PA口,请将PA口接到LED的脚上,然后运行程序
; //显示结果应该是循环点亮LED,
; //请注意主频
; #include <iom16v.h>
; #include <macros.h>
; 
; unsigned LM_Data=1;
; void port_init(void)
; {
	.dbline 16
;  PORTA = 0xFF;
	ldi R24,255
	out 0x1b,R24
	.dbline 17
;  DDRA  = 0xFF;
	out 0x1a,R24
	.dbline 18
;  PORTB = 0x00;
	clr R2
	out 0x18,R2
	.dbline 19
;  DDRB  = 0x00;
	out 0x17,R2
	.dbline 20
;  PORTC = 0x00; //m103 output only
	out 0x15,R2
	.dbline 21
;  DDRC  = 0x00;
	out 0x14,R2
	.dbline 22
;  PORTD = 0x00;
	out 0x12,R2
	.dbline 23
;  DDRD  = 0x00;
	out 0x11,R2
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer1_init _timer1_init fV
	.even
_timer1_init::
	.dbline -1
	.dbline 31
; }
; 
; //TIMER1 initialize - prescale:256
; // WGM: 0) Normal, TOP=0xFFFF
; // desired value: 1Sec
; // actual value:  1.000Sec (0.0%)
; void timer1_init(void)
; {
	.dbline 32
;  TCCR1B = 0x00; //stop
	clr R2
	out 0x2e,R2
	.dbline 33
;  TCNT1H = 0x8F; //setup
	ldi R24,143
	out 0x2d,R24
	.dbline 34
;  TCNT1L = 0x81;
	ldi R24,129
	out 0x2c,R24
	.dbline 35
;  OCR1AH = 0x70;
	ldi R24,112
	out 0x2b,R24
	.dbline 36
;  OCR1AL = 0x7F;
	ldi R24,127
	out 0x2a,R24
	.dbline 37
;  OCR1BH = 0x70;
	ldi R24,112
	out 0x29,R24
	.dbline 38
;  OCR1BL = 0x7F;
	ldi R24,127
	out 0x28,R24
	.dbline 39
;  ICR1H  = 0x70;
	ldi R24,112
	out 0x27,R24
	.dbline 40
;  ICR1L  = 0x7F;
	ldi R24,127
	out 0x26,R24
	.dbline 41
;  TCCR1A = 0x00;
	out 0x2f,R2
	.dbline 42
;  TCCR1B = 0x04; //start Timer
	ldi R24,4
	out 0x2e,R24
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 32
	jmp _timer1_ovf_isr
	.area text(rom, con, rel)
	.dbfile F:\工程文件\AVR光盘\例程\m16\LED跑马灯\C_LEDPMD.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 47
	.dbline 49
	ldi R24,143
	out 0x2d,R24
	.dbline 50
	ldi R24,129
	out 0x2c,R24
	.dbline 51
	lds R2,_LM_Data
	lds R3,_LM_Data+1
	out 0x1b,R2
	.dbline 52
	lsl R2
	rol R3
	sts _LM_Data+1,R3
	sts _LM_Data,R2
	.dbline 53
	tst R2
	brne L4
	tst R3
	brne L4
X0:
	.dbline 54
	ldi R24,1
	ldi R25,0
	sts _LM_Data+1,R25
	sts _LM_Data,R24
L4:
	.dbline -2
L3:
	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 59
; }
; 
; #pragma interrupt_handler timer1_ovf_isr:9
; void timer1_ovf_isr(void)
; {
;  //TIMER1 has overflowed
;  TCNT1H = 0x8F; //reload counter high value
;  TCNT1L = 0x81; //reload counter low value
;  PORTA = LM_Data;
;  LM_Data = LM_Data<<1;
;  if (LM_Data == 0)
;   LM_Data = 1;
; }
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 61
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
	cli
	.dbline 62
;  port_init();
	xcall _port_init
	.dbline 63
;  timer1_init();
	xcall _timer1_init
	.dbline 65
; 
;  MCUCR = 0x00;
	clr R2
	out 0x35,R2
	.dbline 66
;  GICR  = 0x00;
	out 0x3b,R2
	.dbline 67
;  TIMSK = 0x04; //timer interrupt sources
	ldi R24,4
	out 0x39,R24
	.dbline 68
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
L6:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 74
;  //all peripherals are now initialized
; }
; 
; //
; void main(void)
; {
	.dbline 75
;  init_devices();
	xcall _init_devices
	.dbline -2
L7:
	.dbline 0 ; func end
	ret
	.dbend

⌨️ 快捷键说明

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