code to utilise the atmega328 internal clock

hi everyone, sorry if this is in the wrong place firstly.

i read somewhere that the arduino duemilanove chip atmega328 has an internal clock, this was something that made me chose it over pic, plus the really nice ide and language :smiley:

how to i go about getting the chip to use its own internal clock? and is there any disadvantages to useing it compared to the external chip setup?

what i want to-do is get some atmega 328 chips with the bootloader already on, flash them with my program (which would tell it to use the internal clock), then plug the chip into the hardware im making.

again sorry if i have posted this to the wrong section but i figured it would be a programming question due to it being code realated.

thanks everyone

Kris

No code can do that, to use the internal RC oscillator you need an ISP programmer and change the fuses the use the internal source.
There are some differences though, the internal RC is an 8Mhz clock source with a lot of error/deviation, so it is not good if you want to use serial comms, the other thing is that the external clock used is 16Mhz, so you need to compile the code with that in mind, so in the IDE you need to change the target to something like arduino mini or pro mini 8Mhz.

And why cant you use a cristal in your board?

And why cant you use a cristal in your board?

Or even a simple 3 terminal ceramic resonator: Ceramic Resonator 16MHz - COM-09420 - SparkFun Electronics

It will save you a lot of steps and hoops you have to jump through if devating from the arduino standard of external 16mhz clocking.

Lefty

Can you clarify what you mean by clock? Do you mean clock as in time keeping or running the microprocessor?

Sorry everyone what I meant by clock was the microprocessor driver not clock as in kitchen clock :slight_smile:

With the advice in mind about the 8mhz internal clock and it's deviation etc I think I might stick with the external option and keep it running at 16 MHz :slight_smile: makes life easier

Thanks for the replies.

Kris

Kris:
Sorry everyone what I meant by clock was the microprocessor driver not clock as in kitchen clock :slight_smile:

With the advice in mind about the 8mhz internal clock and it's deviation etc I think I might stick with the external option and keep it running at 16 MHz :slight_smile: makes life easier

Thanks for the replies.

Kris

You have made a good choice, grasshopper. :wink:

Kris:
how to i go about getting the chip to use its own internal clock? and is there any disadvantages to using it compared to the external chip setup?

I was drawn to the Arduino for its minimal part count too - here's a step by step on a barebones 8mhz Arduino (near the end):