Forums

Using a 4mhz clock with AVR problems

Started by David Nolen February 2, 2006
Just getting to know embedded programming with the atmega8.

I've had some experience using the PIC chip with MicroCode Studio and have
switched to using the avr-gcc tool chain with the atmega8 chip. I've been
spending a good few weeks getting up to speed on transferring my knowledge
of the PIC to the avr, looking over the docs and all.

I'm using a atmega8 development board from sparkfun w/ the avrisp.  It
works fine. In fact I've got a basic blinking program working on the dev
board itself. The board comes with an 8mhz clock.

Now I'm putting the atmega8 onto a prototyping board with a 4mhz clock. 
I've modified the code the run on a 4mhz clock (like the delay function),
but nothing happens.

When I use the exact same circuit with a 20mhz clock, I get blinking (at a
ridiculous speed of course).

Seems like I'm doing some tiny thing wrong here, any thoughts as to why I
don't get anything while using a 4mhz clock, but get results from a 8mhz
and 20mhz clock?

Many thanks,
David
David Nolen wrote:
> Seems like I'm doing some tiny thing wrong here, any thoughts as to why I > don't get anything while using a 4mhz clock, but get results from a 8mhz > and 20mhz clock?
There are a couple clock source options to explore on the AVR. First is the drive level, which is low by default. Second is the startup time for the clock. Also, what type of device is generating the various clocks (crystal, resonator, ext. oscillator)? IIRC, there's also a fuse setting for this in the same section of the AVR manual. Others here can offer greater insight on the working of different clock sources, but these are a few options to check in the meantime. Cheers, Richard
"David Nolen" <david.nolen@gmail.com> wrote in message
news:pan.2006.02.03.03.51.03.242013@gmail.com...
> Now I'm putting the atmega8 onto a prototyping board with a 4mhz clock. > I've modified the code the run on a 4mhz clock (like the delay function), > but nothing happens.
I'm not surprised. with 4mhz, you'll get an execution speed of around one instruction in 250 seconds.... Just wait a while.... Meindert