oscillator in microcontroller

Thread Starter

bhuvanesh

Joined Aug 10, 2013
268
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
 

Thread Starter

bhuvanesh

Joined Aug 10, 2013
268
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
 

atferrari

Joined Jan 6, 2004
4,771
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.
 

BillB3857

Joined Feb 28, 2009
2,571
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.
 

tshuck

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

Brownout

Joined Jan 10, 2012
2,390
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.
 
Top