Subversion Repositories svn.mios

Rev

Rev 52 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
53 tk 1
; $Id: mios_delay.inc 53 2008-01-30 22:52:41Z tk $
1 tk 2
;
3
; MIOS Delay Routine
4
;
5
; ==========================================================================
6
;
7
;  Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
8
;  Licensed for personal non-commercial use only.
9
;  All other rights reserved.
10
;
11
; ==========================================================================
12
 
13
;; --------------------------------------------------------------------------
14
;;  FUNCTION: MIOS_Delay
15
;;  C_DECLARATION: void MIOS_Delay(unsigned char delay)
16
;;  DESCRIPTION: waits for an exact time<BR>
17
;;  note that this function will not work within an interrupt service routine!
18
;;  IN:	  time in ms (0-255)
19
;;  C_IN: time in ms (0-255)
20
;;  OUT:  -
21
;;  C_OUT:  -
22
;;  USES: BSR
23
;;  EXAMPLE:
24
;;
25
;;	;; wait for exact 250 ms
26
;;	movlw	250
27
;;	call	MIOS_Delay
28
;;
29
;;  C_EXAMPLE:
30
;;
31
;;	// wait for exact 250 ms
32
;;	MIOS_Delay(250);
33
;;
34
;; --------------------------------------------------------------------------
35
MIOS_Delay
36
	SET_BSR	MIOS_DELAY_CTR
37
	movwf	MIOS_DELAY_CTR, BANKED
38
 
39
	andlw	0xff		; exit if value is zero
40
	skpnz
41
	return
42
 
43
MIOS_Delay_Loop
44
	clrwdt
45
	movf	MIOS_DELAY_CTR, W
46
	bnz	MIOS_Delay_Loop
47
	return
48
 
49
;; ==========================================================================
50
 
51
;; --------------------------------------------------------------------------
52
;;  FUNCTION: MIOS_GPCounterGet
53
;;  C_DECLARATION: unsigned char MIOS_GPCounterGet(void)
54
;;  DESCRIPTION: get value of general purpose counter, which is incremented
55
;;  every millisecond
56
;;  IN:	  -
57
;;  C_IN:	  -
58
;;  OUT:  value of general purpose counter in WREG and MIOS_PARAMETER1
59
;;  C_OUT:  value of general purpose counter
60
;;  USES: BSR
61
;; --------------------------------------------------------------------------
62
MIOS_GPCounterGet
63
	SET_BSR	MIOS_GP_CTR
64
	movf	MIOS_GP_CTR, W, BANKED
65
	movwf	MIOS_PARAMETER1
66
	return