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

📄 111.s

📁 温度测量ds18b20.rar
💻 S
字号:
	.module _111.c
	.area text(rom, con, rel)
	.dbfile ..\..\..\..\PROTEU~2\5.avr\19.温度测量ds18b20\1.精确延时\111.c
	.dbfile D:\教程及心得\Proteus\PROTEU~2\5.avr\19.温度测量ds18b20\1.精确延时\111.c
	.dbfunc e delay _delay fV
	.even
_delay::
	.dbline -1
	.dbline 9
; //ICC-AVR application builder : 2008/11/17 1:48:21
; // Target : M8
; // Crystal: 1.0000Mhz
; 
; #include <iom8v.h>
; #include <macros.h>
; #define uchar unsigned char
; void delay()
; {
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 13
; 
; }
; void port_init(void)
; {
	.dbline 14
;  PORTB = 0x00;
	clr R2
	out 0x18,R2
	.dbline 15
;  DDRB  = 0x00;
	out 0x17,R2
	.dbline 16
;  PORTC = 0x00; //m103 output only
	out 0x15,R2
	.dbline 17
;  DDRC  = 0xff;
	ldi R24,255
	out 0x14,R24
	.dbline 18
;  PORTD = 0x00;
	out 0x12,R2
	.dbline 19
;  DDRD  = 0x00;
	out 0x11,R2
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 24
; }
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 26
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
	cli
	.dbline 27
;  port_init();
	rcall _port_init
	.dbline 29
; 
;  MCUCR = 0x00;
	clr R2
	out 0x35,R2
	.dbline 30
;  GICR  = 0x00;
	out 0x3b,R2
	.dbline 31
;  TIMSK = 0x00; //timer interrupt sources
	out 0x39,R2
	.dbline 32
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
L3:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 37
;  //all peripherals are now initialized
; }
; 
; void main(void)
; {
	.dbline 38
;   init_devices();
	rcall _init_devices
	.dbline 42
;    /*精确延时111us,晶振4MHz */
; /*us级精确延时 766us/晶振以内 延时=1+n*3 */
; // CLI;//屏蔽中断
; asm("LDI R18,147");//1t ,寄存器R15~R30
	LDI R18,147
	.dbline 43
; asm("CLZ");//1t
	CLZ
	.dbline 44
; asm("LOOP1:DEC R18");//1t
	LOOP1:DEC R18
	.dbline 45
; asm("BRNE LOOP1");//1t或2t//标志位Z是0就转移
	BRNE LOOP1
	.dbline 46
; asm("NOP");//1t
	NOP
	.dbline 47
; asm("NOP");//1t
	NOP
	.dbline 52
; // SEI;
; /*us级精确延时 766us/晶振以内,可用nop补足余数*/
; /*精确延时0ms 111us */
; 
; 	PORTC=0xff;
	ldi R24,255
	out 0x15,R24
	.dbline -2
L4:
	.dbline 0 ; func end
	ret
	.dbend
; }

⌨️ 快捷键说明

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