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

📄 delay.asm

📁 温度测量
💻 ASM
字号:
;************************************************
;* Delay routines for AVR's			*
;*						*
;* Copyright 2001-2003 Wayne Peacock		*
;* First Revision 6th Jan 2001			*
;* Version 1.01					*
;************************************************
;* Disclaimer:					*
;* The Author takes no responsibility for the 	*
;* use of this code. Use at your own risk!	*
;* 						*
;* This code or part there of is licensed only 	*
;* for private use and NOT for commercial use.	*
;* 						*
;* Please contact the Author 'Wayne Peacock' 	*
;* <wpeacock@senet.com.au> before using the code*
;* or part there of in a commercial project.	*
;************************************************
       
; Requires the following registers
;.def	count1	= r26		
;.def	count2	= r27

wait_long:
	ldi	count1, 0xff
	rjmp	delay

;************************************************
;* 2ms Delay	(8Mhz)				*
;*						*
;* Input:	None				*
;* Returns:	None				*
;* Requires:	count1				*
;*		count2				*
;************************************************

wait_2ms:
	ldi	count1, 0x15		; 2ms delay

;************************************************
;* Delay	(8Mhz)				*
;*						*
;* Input:	count1 (1 = appox. 100us)	*
;* Returns:	None				*
;* Requires:	count2				*
;************************************************
	
delay:	ldi	count2,0xff		; (1)  1 count appox. 100us
w01:	dec	count2			; (1*255)
	brne	w01			; (2*255)
	dec	count1			; (1)
	brne	delay			; (2)
	ret				; (4)

;************************************************
;* Delay	(4Mhz)				*
;*						*
;* Input:	count1 = n (delay = 5.25n+2us)	*
;* Returns:	None				*
;* Requires:	count2				*
;************************************************
	
delayX5us:
	ldi	count2,0x06		; (1)  1 count appox. 5us
del01:	dec	count2			; (1*255)
	brne	del01			; (2*255)
	dec	count1			; (1)
	brne	delayX5us		; (2)
	ret				; (4)

;************************************************
;* Short Delay 2us	(4Mhz)			*
;*						*
;************************************************
	
delay2us:

	nop
	ret
	

⌨️ 快捷键说明

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