Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

detail about delay.h header file

Status
Not open for further replies.

shivachellam

Newbie level 6
Joined
Jan 28, 2009
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,400
delay header file

hi

i am interfacing the lcd with pic16f877a and i got the source code . in tat code i got the header file delay.h .i cant understand about this file plz help me and i attached the file ...

/*
* Delay functions for HI-TECH C on the PIC
*
* Functions available:
* DelayUs(x) Delay specified number of microseconds
* DelayMs(x) Delay specified number of milliseconds
*
* Note that there are range limits: x must not exceed 255 - for xtal
* frequencies > 12MHz the range for DelayUs is even smaller.
* To use DelayUs it is only necessary to include this file; to use
* DelayMs you must include delay.c in your project.
*
*/

/* Set the crystal frequency in the CPP predefined symbols list in
HPDPIC, or on the PICC commmand line, e.g.
picc -DXTAL_FREQ=4MHZ

or
picc -DXTAL_FREQ=100KHZ

Note that this is the crystal frequency, the CPU clock is
divided by 4.

* MAKE SURE this code is compiled with full optimization!!!

*/

#ifndef DELAY_ROUTINE //-- Check if already loaded!!!

#define DELAY_ROUTINE //-- MAKE SURE CANNOT RELOAD
#ifndef XTAL_FREQ
#error NO XTAL_FREQ DEFINED - Is Required for DelayUs!
#define XTAL_FREQ 8MHZ /* Crystal frequency in MHz */
#endif

#define MHZ *1000 /* number of kHz in a MHz */
#define KHZ *1 /* number of kHz in a kHz */

#if XTAL_FREQ >= 12MHZ
#if XTAL_FREQ >= 20MHZ
void DelayUs(unsigned char x)
{
unsigned char count,_dcnt;
for(count=0;count<x;count++)
{
_dcnt= ((XTAL_FREQ)/(8MHZ)); //-- 1us worth of delay
while(--_dcnt !=0);
}
}
#else
#define DelayUs(x) { unsigned char _dcnt; \
_dcnt = (x)*((XTAL_FREQ)/(12MHZ)); \
while(--_dcnt != 0) \
continue; }
#endif
#else

#define DelayUs(x) { unsigned char _dcnt; \
_dcnt = (x)/(12MHZ/(XTAL_FREQ))|1; \
while(--_dcnt != 0) \
continue; }
#endif

extern void DelayMs(unsigned char);
#endif


thank you.......................
 

delay.h

i am interfacing the lcd with pic16f877a and i got the source code . in tat code i got the header file delay.h i can understand about this file pl help me i attached the file ...

your question is not clear, i guess you meant u "can't" understand the delay.h file???
please preview before posting.

This delay.h file is used for providing pre-defined and accurate delay in milli seconds and micro seconds. It takes the crystal frequency as inputs for clks and calculates the mili seconds and microseconds and provides the required delay. As it says the range should be considered.

what lines of code you did not understand?


Surya
 

delay + header file

i think ur slightly confused with the preprocessor directives..........

in that it is like a simple if else, where in #if u give out a condition and if it's true the following statements wil b executed or it leads to #else condition

here based on crystal frquency he is switching

as it is already inbuilt u need not to worry about it . simply use the delay function by calling it as delay(x);
 
delay function with its header file

thankq sorry for the mistake in the text. mainly i dont know about the calculation will u explain for me thank u,..............
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top