delay.c
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Simple Delay Routines
4  *
5  *********************************************************************
6  * FileName: delay.c
7  * Dependencies: delay.h
8  * Processor: dsPIC33F
9  * Complier: MPLAB C30 v2.01.00 or higher
10  *
11  * Company: Microchip Technology, Inc.
12  *
13  * Software License Agreement
14  *
15  * The software supplied herewith by Microchip Technology Incorporated
16  * (the “Company”) for its dsPIC30F Microcontroller is intended
17  * and supplied to you, the Company’s customer, for use solely and
18  * exclusively on Microchip's dsPIC30F Microcontroller products.
19  * The software is owned by the Company and/or its supplier, and is
20  * protected under applicable copyright laws. All rights are reserved.
21  * Any use in violation of the foregoing restrictions may subject the
22  * user to criminal sanctions under applicable laws, as well as to
23  * civil liability for the breach of the terms and conditions of this
24  * license.
25  *
26  * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
27  * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
28  * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
29  * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
30  * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
31  * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
32  *
33  * Author Date Comment
34  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35  * Richard Fischer 7/14/05 Initial release for LCD support
36  * Priyabrata Sinha 1/27/06 Ported to non-prototype devices
37  *
38  ********************************************************************/
39 
40 #include "delay.h"
41 #include "../AttitudeManager/main.h"
42 
43 unsigned int temp_count;
44 
45 void Delay( unsigned int delay_count )
46 {
47  delay_count *= Delay_1mS_Cnt;
48  temp_count = delay_count +1;
49  asm volatile("outer: dec _temp_count");
50  asm volatile("cp0 _temp_count");
51  asm volatile("bra z, done");
52  asm volatile("do #3200, inner" );
53  asm volatile("nop");
54  asm volatile("inner: nop");
55  asm volatile("bra outer");
56  asm volatile("done:");
57 }
58 
59 
60 void Delay_Us( unsigned int delayUs_count )
61 {
62  delayUs_count *= Delay1uS_count;
63  temp_count = delayUs_count +1;
64  asm volatile("outer1: dec _temp_count");
65  asm volatile("cp0 _temp_count");
66  asm volatile("bra z, done1");
67  asm volatile("do #15, inner1" );
68  asm volatile("nop");
69  asm volatile("inner1: nop");
70  asm volatile("bra outer1");
71  asm volatile("done1:");
72 }
73 
#define Delay1uS_count
Definition: delay.h:8
void Delay_Us(unsigned int delayUs_count)
Definition: delay.c:60
void Delay(unsigned int delay_count)
Definition: delay.c:45
#define Delay_1mS_Cnt
Definition: delay.h:11
unsigned int temp_count
Definition: delay.c:43