delay.asm

来自「DS1820 1-wire temp sensor AVR asm Progra」· 汇编 代码 · 共 79 行

ASM
79
字号
;************************************************
;* Delay routines for AVR's			*
;*						*
;* Copyright 2001-2003 Wayne Peacock		*
;* Wayne Peacock 6th Jan 2001			*
;* Version 1.00 				*
;************************************************
;* See Schematic for Hardware connections	*
;* 						*
;* 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 
;.def	count1	= r26		
;.def	count2	= r27


;************************************************
;* 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 + =
减小字号Ctrl + -
显示快捷键?