electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

xtal(oscillator problem) - a way to generate 1 sec delay


Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> xtal(oscillator problem) - a way to generate 1 sec delay
Author Message
siddhukb



Joined: 07 Aug 2008
Posts: 3


Post29 May 2009 3:47   

xtal oscilator problem


I am using using a 12mz crystal and atmega 16 and mikroc pro for avr complier.
when i give a delay of 1 sec the led blinking doesnt blink at 1 sec,it takes too long to blink.
Code:
delay_ms(1000);


do i need to configure anything?
or is there any other way to generate 1 sec delay.?

thanking you,
siddharth
Back to top
Google
AdSense
Google Adsense




Post29 May 2009 3:47   

Ads




Back to top
sau_sol



Joined: 27 Feb 2008
Posts: 249
Helped: 27
Location: India


Post29 May 2009 5:19   

Re: xtal(oscillator problem)


use a timer with say 10ms of overflow then increment a variable in interrupt for 100 so you will get
10ms *100 = 1000ms = 1s delay

so calculate according the data sheet the value to be fed in the timer
Back to top
jumper2high



Joined: 24 May 2009
Posts: 62
Helped: 3
Location: Serbia


Post29 May 2009 10:54   

Re: xtal(oscillator problem)


siddhkub, you should check the settings in MikroC, specifically make sure you've selected the right frequency in there. The "real time" delays depend on CPU clock, since at 4Mhz you need 1.000.000 clock cycles to generate a 1 second delay, but at 48Mhz you need 12.000.000 clock cycles for the same delay.

If MikroC thinks you're running at 48Mhz, but you're actually running at 4 Mhz, the compiled code will have delays 12 times longer than what you wanted.
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> xtal(oscillator problem) - a way to generate 1 sec delay
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
MAX7032 - way to connect some other XTAL (1)
Xtal oscillator (1)
Xtal Oscillator Simulation (3)
Triggered XTAL Oscillator (3)
Regd XTAL OSCILLATOR design (6)
why xtal oscillator startup sim need ic current in inductor? (3)
Do I really need 2 Xtal Oscillator when Using 2 PIC micro? (3)
BJT for the lowest phase noise XTAL oscillator (54)
way to generate locked signal (3)
the way to generate register (6)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS