delay ranging from 100us to 1 sec

Status
Not open for further replies.

nikhil9967

Newbie level 2
Joined
Mar 1, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,294
Is it possible to generate a delay ranging from 100us to 1sec using pic16f877a. (The user should be able to input the value.) If yes, then how?
 

If you work with a crystal multiple of 2 ( i.e. 32,768 KHz used at RTC ), yes you can obtain the exact value generating some interruption.
However, due that frequency is very slow to most applications, the best choice could be using this at external oscilator generating interrupt on pin.

+++
 
Knowing your uC freq. you could loop doing nothing as many times as needed.
**broken link removed** is asm code generator for this.
Or if you're using C there's probably some delay function provided with your compiler.
Hi-tech has __delay_ms and __delay_us for example.

regards.
 
Just remarking that if absolute precision be required ( i.e, to avoid cummulative error ) you also could use a crystal of 3,27680MHz - not so usual like the other used at RTC. If this oscilator inputs at a 16-Bits timer, can generate precise interruption of 10ms ( 100Hz ).


3.27680MHZ HC49U



+++
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…