[[SOLVED]] Can an Arduino alter it's own clock speed ?

So can you supply the arduino clock frequency by a chip instead of a fixed oscillator ? a chip with a variable frequency output ?

Yes you can do that. Although I am not sure why you would want to do so.

Grumpy_Mike: Yes you can do that. Although I am not sure why you would want to do so.

i think that must be useful somehow , though i thought that was impossible . can you recommend a chip for that ?

There are better ways to do this, but something I would consider just for kicks:

20mhz or 16mhz can oscillator feeding (not crystal, a real full swing oscillator)... 74HC590 8 -state binary counter feeding (or similar, you can use two older 4-bit counters too).... 74HC151 8-channel multiplexer, taking one of the counter taps and feeding the clock on the micro-controller.

With three outputs, you can select the clock, or a half, quarter, eigth, sixteenth, thirty-second, sixty-fourth,, or one-hundred-and-twenty-eigth of the clock. Pull C, B, and A on the MM74HC151 high with a 10K resistor and whatever counter tap you send to D7 will be the initial clock.

https://www.fairchildsemi.com/datasheets/MM/MM74HC151.pdf http://www.nxp.com/documents/data_sheet/74HC590.pdf

Probably any PLL IC will give you a more flexible solution, but I doubt there is one that gives you a stone-cold obvious three-pin, pin-programmable solution like this one.

Your topic and your message, ask two different questions.

amine2: Can an Arduino alter it's own clock speed ?

No

amine2: So can you supply the arduino clock frequency by a chip instead of a fixed oscillator ?

Yes

amine2: i think that must be useful somehow

Useful as a "because you can" project. Not much practical use.

Yes, you can apply different prescalers to the system clock.

Why? What are you really trying to do?

MorganS: Yes, you can apply different prescalers to the system clock.

Why? What are you really trying to do?

You can? I know you can do this for the timer/counter being driven by the clock, but for the clock itself? How? I know about the CLKDIV8 fuse, but that is it. Maybe he wants to slow the whole thing down for power purposes or to make it quiet...

From the data sheet:

The ATmega48A/PA/88A/PA/168A/PA/328/P has a system clock prescaler, and the system clock can be divided by setting the ”CLKPR – Clock Prescale Register” on page 387. This feature can be used to decrease the system clock frequency and the power consumption when the requirement for processing power is low. This can be used with all clock source options, and it will affect the clock frequency of the CPU and all synchronous peripherals.

It's amazing what you can learn when you spend YOUR OWN TIME to actually READ a DATASHEET instead of just always posting on the forum for your answers everytime you have a question about anything.

raschemmel: It's amazing what you can learn when you spend YOUR OWN TIME to actually READ a DATASHEET instead of just always posting on the forum for your answers everytime you have a question about anything.

Hey , i did search for this , but couldn't find anything on it (y) . and i do not post on the forum whenever i have a question about anything ...

Jremington : i am not looking for an internal solution for this , an external chip should do it and the arduino should communicate with the chip .

Hey , i did search for this , but couldn't find anything on it (y) . and i do not post on the forum whenever i have a question about anything ...

READ YOUR POST TITLE . The arduino is an ATmega328. If you didn't "SEARCH" the ATmega328 DATASHEET, then you are wasting your time because that's where the clock prescaler data is.

It's stupid to use an external chip to control the ATmega328 clock when it can do it using prescaler commands.

Jremington : i am not looking for an internal solution for this , an external chip should do it and the arduino should communicate with the chip .

Now that's really smart. Have a chip that has it's own clock prescaler control ask another chip to change it primary clock frequency. Where did you come up with that genius idea ?

That prescaler sounds like it essentially is the same circuit that I was talking about (a counter and a multiplexer, in this case the multiplexer is selected directly from a register). I wasn’t aware the 328P had this feature, just the prescaler for the counter/timers. It does everything my circuit did:

prescaletable.png

I have to agree, unless there is an academic reason for doing this externally (e.g. professor said to do it that way) or you absolutely need a different scale factor than a power-of-2’s based one, I don’t see a reason to build the circuit. If you need that clock on an external pin to synchronize external circuits, you can set CKOUT fuse bit to zero to send it to PORTB0.

JoeN:
That prescaler sounds like it essentially is the same circuit that I was talking about (a counter and a multiplexer, in this case the multiplexer is selected directly from a register). I wasn’t aware the 328P had this feature, just the prescaler for the counter/timers. It does everything my circuit did:

prescaletable.png

I have to agree, unless there is an academic reason for doing this externally (e.g. professor said to do it that way) or you absolutely need a different scale factor than a power-of-2’s based one, I don’t see a reason to build the circuit. If you need that clock on an external pin to synchronize external circuits, you can set CKOUT fuse bit to zero to send it to PORTB0.

thank you very much JoeN :slight_smile: PROBLEM SOLVED , i want to give you a bucket load of Karma , too bad i can only provide one for now .

amine2: thank you very much JoeN :) PROBLEM SOLVED , i want to give you a bucket load of Karma , too bad i can only provide one for now .

What? No karma for reply #7, which provided the same answer first? :)

So what you're saying is that telling you to "read the datasheet" doesn,'t solve your problem because you can't read but telling you what the datasheet says exactly DOES solve yiur problem and you change from NOT wanting use an INTERNAL solution to wanting to give a boatload of karma the person who tells you what the datasheet says and how to use the internal solution. Why don't just be honest and admit "I can't read a datasheet , can you please tell me how to do this ?" Do you think you are fooling anyone with you're wierd questions ? Why didn't you just ask "how do you change the ATmega328 Prescaler make it run at a slower speed ?

Why do you want to reduce the clock speed of your Arduino?

It's a bit like saying can we return to the days when you had to have a man with a red flag walking in front of your car, so that you would observe the 4 miles per hour speed limit.

http://en.wikipedia.org/wiki/Locomotives_on_Highways_Act_1896

I think it is valid to ask the OP "Why?" since they are on a public forum asking for free help. The answer may help others and this is about the free EXCHANGE of ideas and knowledge.

Dismissing it without knowing that answer though? To what purpose?

Just to hazard a guess, power consumption and product life? Sometimes "hobby" is about optimizing things or doing it "Just Cuz".

outofoptions: I think it is valid to ask the OP "Why?" since they are on a public forum asking for free help

I did ask in reply #1, but it never got answered.

Product life?

Do you imagine the microcontroller has a limited number of clock cycles in its lifetime, as some people conceptualise that a human has a certain allocated number of heartbeats? :astonished:

hmmm ... i am not a liar , so i am gunna say this one . yes , i actually am not capable of reading a datasheet . i can search for specific elements and get snippets of information from a datasheet , but reading a full datasheet is something i am not capable of . i am inexperienced i admit , though when i get the proper experience i might get to help people in the future so answering my questions is a good investment in life .