Using a 4mhz clock with AVR problems

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

Reply to
David Nolen
Loading thread data ...

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

Reply to
Richard H.

I'm not surprised. with 4mhz, you'll get an execution speed of around one instruction in 250 seconds.... Just wait a while....

Meindert

Reply to
Meindert Sprang

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.