# oscillator in microcontroller

Discussion in 'Embedded Systems and Microcontrollers' started by bhuvanesh, Dec 23, 2013.

1. ### bhuvanesh Thread Starter Member

Aug 10, 2013
268
2
if we see in arduino we have crystal oscillator in its board.it produce square wave of frequency about 16 mhz or something else.My question is how it would be related to input.explain me basically with some examples.thank you in advance

2. ### tubeguy Well-Known Member

Nov 3, 2012
1,157
197
I'll start.

The crystals frequency determines the speed at which the Arduino executes instructions.

3. ### bhuvanesh Thread Starter Member

Aug 10, 2013
268
2
this is what i exactly mean if we write a code to off some thing after 5 seconds.it will calculate time from oscillator.it off after16mhz*5 cycles am i right.please someone come forward.i am in little choas

Feb 19, 2010
3,382
495

5. ### atferrari AAC Fanatic!

Jan 6, 2004
2,645
759
Those generic questions are better served reading the basics of digital techniques. While a datasheet is not going to mention all the basics, google for it and then read a datasheet to complement.

6. ### MrChips Moderator

Oct 2, 2009
12,421
3,355
An alternative is to tell us what you don't understand and we will attempt to explain it for you.

7. ### BillB3857 Senior Member

Feb 28, 2009
2,400
348
As an example, when you tell the Arduino by code to delay(1000);, the compiler lets the guts of the chip know to count 16 million clock cycles while doing nothing else.

8. ### tshuck Well-Known Member

Oct 18, 2012
3,531
675
It is also important to note that these are machine instruction (think assembly programming) times, not instructions done in Processing.

9. ### Brownout Well-Known Member

Jan 10, 2012
2,375
998
Typically, there are some numbers of clock cycles per delay. So, for example, if you want to delay 5ms, your clock is 16mhz and there are 4 clock periods per delay count:

delay = count*clock_per_count*clock_period

substituting some numbers:

5ms = count*4*(1/16e6) or count = 5ms*16e6/4 = 20,000.