| Author |
Message |
siddhukb
Joined: 07 Aug 2008 Posts: 3
|
29 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.
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

|
29 May 2009 3:47 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
sau_sol
Joined: 27 Feb 2008 Posts: 249 Helped: 27 Location: India
|
29 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
|
29 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 |
|
 |