108

The datasheet for the ATTiny13A, for instance, lists Min frequency of 0 MHz. Does this mean the clock can be run at any arbitrarily low frequency with no ill effects? I'm assuming it draws lower current at lower clock speeds? Does 0 MHz mean you can stop the clock completely, and as long as power is still applied, it will remember its state indefinitely?

endolith
  • 28,494
  • 23
  • 117
  • 181
  • 37
    I would like to add, this is an excellent question. Most senior EEs do not take the time to actually read and think about datasheets, which is either a complement for you or an insult to them, I would like to imply both. – Kortuk Dec 16 '09 at 06:44
  • I am not entirely sure that the internal RC oscillator is shut down unless you specifically instruct it to (through various power saving options). Not sure what it is used for, but at least for EEPROM and probably ADC. – jippie Dec 18 '13 at 20:42
  • 1
    @jippie what internal RC you are saying? ATMegaX for example, has the internal RC for the system clock (normally 8Mhz, with optional div 8 prescaler), it has the watchdog oscillator. The system clock is fuse selected and is probably off when using external clock. The others as you said may be disabled by power-saving modes, but I doubt will stop by the system clock. – Diego C Nascimento Dec 19 '13 at 00:57

5 Answers5

79

Yes. If the datasheet says "fully static operation", then you can clock it at any speed, even 0 Hz. A "dynamic" chip needs to have a clock at a specific rate or it loses its state.

todbot
  • 4,616
  • 23
  • 26
  • 2
    do you have an example of a micro that allows this? – MrEvil Dec 16 '09 at 10:21
  • 5
    Microcontrollers which contain on-chip flash may specify a minimum (and maximum) flash clock speed when writing to flash. However, when reading from flash, this doesn't apply. – Steve Melnikoff Dec 16 '09 at 13:22
  • 10
    MrEvil, the Atmel AVR ATtiny series mentioned in the question is fully static, as I think most all Atmel AVR chips. And I think most all of Microchip's PIC microcontrollers. – todbot Dec 16 '09 at 17:56
  • I would like to add MSP430s to todbot's list. Most modern microcontrollers do, the dynamic kind are a headache to design for, so most do not. – Kortuk Dec 16 '09 at 18:11
  • 8
    Actually, I think the ADC in the ATTiny13A doesn't work at low frequencies, maybe because of the sample-and-hold capacitor decaying? "By default, the successive approximation circuitry requires an input clock frequency between 50 kHz and 200 kHz to get maximum resolution. ... The ADC module contains a prescaler, which generates an acceptable ADC clock frequency from any CPU frequency above 100 kHz." – endolith Dec 17 '09 at 15:26
  • 8
    endolith -- I agree, ADCs usually don't work at low frequencies. As far as I can tell, everything else on practically all modern microcontrollers continue to work fine all the way down to "0 Hz", aka "pause indefinitely". In particular, many microcontrollers have a "low-power sleep" mode that stops all clocks, until something -- typically a person pushing a button -- wakes it up and it resumes right where it left off. http://en.wikipedia.org/wiki/Static_logic_(digital_logic) – davidcary Jun 15 '10 at 22:52
  • 1
    The RCA 1802 ( http://en.wikipedia.org/wiki/RCA_1802 ) was, AFAIK the first micro to allow static operation, way back in 1976. – tcrosley Apr 09 '11 at 23:47
  • 1
    However, the ADC may be considered to be a peripheral from the perspective of the clock range for the CPU core. Static operation seems not to be a big deal. You can cob together a sequential circuit using TTL chips and it will work down to arbitrarily low clock speeds. It's things like the presence of DRAM that needs refresh that create challenges. – Kaz Dec 18 '13 at 22:32
  • 1
    @Kaz: When fabricating an NMOS device, it's more power efficient to unconditionally pull a bus high on one half of a cycle and then then conditionally pull it low on the other half of a cycle, than to use a passive pullup which must be strong enough to pull the bus high within a cycle. The former approach will waste current proportional to the *actual* bus capacitance each cycle, while the latter will waste current proportional to the actual sourcing current of a circuit whose worst-case (lowest) current sourcing ability must be sufficient to power the worst-case (maximum) bus capacitance. – supercat Jun 22 '15 at 17:06
  • 1
    @Kaz: Many NMOS devices like the 6502 thus used dynamic logic for things like bus driving, and not just dynamic "memory". Using dynamic bus driving means that capacitance/leakage ratios need to be ensured, but otherwise allows much more generous margins on many other fabrication parameters than would be possible in a fully-static design. – supercat Jun 22 '15 at 17:08
24

I am posting another answer, just because the last question you had was not answered before.

Todbot is completely correct. It will also draw lower power at lower speeds. It also means if you supply it's clock from another processor, for example, you could stop supplying it at any point and then start clocking it later, as long as you do not go faster than max speed, you will be fine.

The Chips I have get an order of magnitude change between 32768Hz oscillator and a 1MHz one. I have had applications where I did not need speed, I just needed another little guy doing some basic data handling for me.

Hope this helps.

Kortuk
  • 13,362
  • 8
  • 60
  • 85
  • 11
    I've always wanted to run a microcontroller's clock line with a pushbutton. Let the human be the clock. :) On a serious note, a really nice things about these static designs is their power consumption is linear with clock speed: slow down the clock and use less power. This can be really handy. – todbot Dec 16 '09 at 06:27
  • 6
    Yes, but I do like to note, power consumption is a linear function with an offset, even without a clock they still consume power, especially with any outputs being driven. We just got new interns at my work, I will suggest we use a pushbutton and see what happens. – Kortuk Dec 16 '09 at 06:39
  • 16
    @todbot Nice idea. :-) But make sure to debounce the pushbutton. – starblue Dec 16 '09 at 08:49
  • 5
    Try with a "grind crank" (as in the Jargon meaning: http://www.jargon.net/jargonfile/g/grindcrank.html ) :-)) (and yes, many years ago I built one to step thru code when I was using Turbo Pascal at school :-) – Axeman Dec 16 '09 at 09:19
  • 1
    @todbot It's not really far-fetched or difficult, if you can accept a rough abstraction. There are several examples of people using such gadgets to teach how computers work. Myke Predko has a really good book, and it even comes with PCBs (though not for the computer project): http://www.amazon.com/Digital-Electronics-Guidebook-Michael-Predko/dp/0071377816/ref=sr_1_1?ie=UTF8&qid=1260970753&sr=8-1 – Lou Dec 16 '09 at 13:41
  • @everyone, I am 99% sure todbot knew that it would work and intended it as a joke since most RISC processors need so many clock ticks that it would be a long time.@starblue, As I was typing earlier I thought about joking about forgetting to debounce to get a higher clock rate per push. – Kortuk Dec 16 '09 at 18:10
  • @Axeman - the jargon file claims that the "grind crank" is mythical. Here's evidence to the contrary: http://www.computerhistory.org/babbage/. The crank on the right drives the computer; the one on the left drives the printer. You can get a better feel for the size of the thing by watching the video on that page; it's about eight feet tall. – Pete Becker Apr 17 '13 at 13:34
  • @PeteBecker: The Curta Calculator also had a crank, which could actually be pulled up or down to select addition or subtraction. – supercat Oct 19 '16 at 14:03
20

Most modern microcontroller designs will work with any pattern on their clock input, provided only that no high pulse is below a certain minimum length, no low pulse is below a certain minimum length, and no low-high-low or high-low-high pulse pair is below a certain length. Essentially what happens is that after the chip does all of the actions associated with a particular clock edge, the chip will be in a state where it is doing nothing but waiting for the next clock edge. If the next clock edge doesn't arrive for ten days then (unless the chip has some external watchdog) the chip will be in the same state as if the edge had arrived the moment the chip was ready for it.

Note that in general, pausing the clock on a microcontroller will reduce current consumption substantially, but not as much as using the "sleep" feature. Most microcontrollers' current consumption in "run" mode can be pretty well estimated as a constant quiescent current plus a certain amount of current per cycle per second (which might be more 'naturally' expressed as charge per cycle). For example, a chip might have a quiescent current of 10uA, plus a current of 0.1mA/MHz (100pC/cycle). Running such a chip at 10MHz would yield a current of 1.01mA. Running it at 1MHz would yield 0.11mA. Running it at 100KHz would yield 0.02mA. Running it at 1Hz woudl yield 0.0100001mA. On the other hand, the chip might offer a sleep current of 1uA. Generally, entering sleep mode will completely power off areas of the chip that aren't going to do anything useful while the chip is sleeping, thereby avoiding any leakage current such areas might have. It will in some cases also reduce the voltage to areas like register files to a level where the register files can hold their contents, but not access them very quickly (since they won't be accessed at all, access speed doesn't matter).

Some older microprocessors, microcontrollers, and other devices had maximum clock-high and/or clock-low times. Such processors made use of dynamic logic to save circuitry. As an example of dynamic logic, consider a shift register: a typical static register bit requires a two-transistor circuit to hold the value, while a dynamic register bit holds the value on the gate of a readout transistor. A two-phase-clocked dynamic shift register may be realized in NMOS using four NFETs and two resistors per bit. A static shift register would require eight NFETs and four resistors per bit. Dynamic logic approaches are not nearly so common today. Back in the 1970's, gate capacitance was substantial and there wasn't any getting rid of it. There was thus no particular reason not to take advantage of it. Today, gate capacitance is generally much lower, and chip makers are actively trying to reduce it further. Making dynamic logic work reliably would often require deliberately working to increase gate capacitance. In most cases, the extra chip area needed to increase capacitance could be just as effectively used to add more transistors so as to make the capacitance unnecessary.

supercat
  • 45,939
  • 2
  • 84
  • 143
  • You mention NMOS and IIRC there is a connection between the popularity of dynamic logic and complementary MOS (CMOS) not being available yet. – jpc Apr 09 '11 at 21:13
  • @jpc: I've examined schematics of various NMOS chips--some in great detail, including the Atari 2600 TIA which is a real work of genius--people are still finding new things to do with it three decades later. I think one advantage of NMOS versus CMOS from a design-convenience standpoint is that 'shoot-through' (accidental simultaneous activation of high- and low-side drive) is a non-factor, though I'll confess some curiosity as to why CMOS isn't run at a low enough voltage that the cross-over point on an input would leave high and low side drivers off, rather than activating both. – supercat Apr 09 '11 at 23:31
  • @jpc: In NMOS, it's possible to implement an XOR gate with two transistors and two resistors, if the inputs are sufficiently "strong". Even if one has to add inverters to both inputs, a four-transistor four-resistor xor gate would be better than many other approaches. I've never seen the approach used, though, even though I designed a similar circuit using BJT's around 1978 (the design concept would work better with MOSFETS, but I didn't know anything about them). – supercat Apr 09 '11 at 23:34
  • 2
    +1 - I feel like the real gem you mentioned here is that lower clock speeds do save power, but not as much as sleep modes which are specifically designed to optimize power savings. My gut tells me that you'll save more power running a fast oscillator combined with judicious use of sleep mode, over running at a really low frequency constantly. – Joel B Jun 28 '12 at 14:02
  • @JoelB: That depends on many factors. On many processors, there is a delay between turning on a fast clock and being able to actually use it; during this time, one will waste power. If one would have to wake up e.g. 100x/second, it may be better to run slowly continuously than to be constantly starting and stopping. On the other hand, if one is going to be starting and stopping the fast clock, it may be good to minimize the amount of time that it's running to the extent one can do so without wasting additional energy. For example... – supercat Jun 28 '12 at 14:54
  • ...if the CPU has a "high core voltage mode" which can run up to 16MHz and a "low core voltage mode" which can run up to 4Mhz, switching between "stop" and "4MHz" modes might be better than switching between "stop" and "1MHz" modes if the former would require spending less time awake; even if switching to 16Mhz mode would reduce waking time further, it probably wouldn't be worth the extra energy cost. – supercat Jun 28 '12 at 14:57
  • @supercat - It absolutely does depend on numerous factors (some unquantifiable). In the end, energy is king and you would have to tailor your clock scheme with the knowledge of your application/processor and how much/often processing will occur. I just wanted to point out the "forest-for-the-trees" perspective you brought by mentioning sleep mode in this discussion. My gut tells me that there is still a lot of production code with 'while(1){_nop;}' that well-intentioning engineers think they are saving the most power by running at a slower speeds instead of implementing sleep mode properly. – Joel B Jun 28 '12 at 15:37
  • @JoelB: Your comment reminded me of a problem some fellow engineers were having some time back: the audio output of the system would sometimes buzz annoyingly. It turned out that whenever the OS detected that the CPU had nothing to do, it would put it to sleep. This reduced power consumption, in turn allowing VDD to rise slightly. Every 10ms, the CPU would wake up to see if there was more to do. The problem was fixed by adding something like: "do {} while(audio_powered_on());" before the "sleep()" statement in the idle task since, in that situation, saving power *wasn't* king. – supercat Jun 28 '12 at 15:45
  • @supercat - Sounds like this story proves just the opposite. A properly spec'd/regulated/filtered/decoupled power supply should have been designed so that it would not have discernible effects on the audio over the expected operational load of the processor. So it seems like power (or more specifically _power supply design_) is still king. Great fix by the way! – Joel B Jun 28 '12 at 16:23
  • What do you mean by sleep having less power than clock stop? On atmel for example, the only thing different between sleep and run, it's which clocks are stopped. There is nothing else a sleep can do? Unless it's cuts power to sections? – Secto Kia Oct 19 '16 at 01:53
  • @JoelB: Power supply filtering has three aspects: (1) prevent junk inside from getting outside; (2) prevent junk outside from getting inside; (3) prevent changes in current draw from changing inside voltage. Optimizing for #1 will generally adversely impact #3. If the device had used entirely separate supplies for the audio and CPU, that would have avoided the problem but required more power supply electronics; the problem was that the CPU and audio circuitry were on the same side of the same filter. – supercat Oct 19 '16 at 14:00
  • @SectoKia: The alternative wasn't between clock-stop and sleep but between sleeping when idle versus executing useless instructions to ensure more uniform power draw. Though many CPUs do cut power to significant sections in their lower-power sleep modes. – supercat Oct 19 '16 at 14:01
14

Yes, you can stop the clock completely and restart it at a later time without consequences. You could even replace the clock by a pushbutton and go through your program literally step by step (frequency: about 0.1 Hz).

Power is almost linear with frequency: at 10 MHz the microcontroller will consume 10 times as much power as at 1 MHz. This does not mean that at 0 Hz the consumption is completely zero, though. There's always static dissipation, but that's very low, typically 1 uA or less.

PS: notice that the ADC does have a minimum operating frequency. If the frequency is too low the capacitor over which the voltage is measured will discharge too much and your measurement will be wrong.

flup
  • 902
  • 7
  • 14
12

Coming late to this question, it reminded me of a project I saw a while back.

It's a bat detector which uses a PIC running at zero Hz for most of the time, and is then clocked by the very signal it is detecting.

http://www.micro-examples.com/public/microex-navig/doc/077-picobat.html

Buzby
  • 456
  • 4
  • 6
  • 7
    In [this project](http://scanlime.org/2008/09/using-an-avr-as-an-rfid-tag/) the signal is both the clock *and the power to the chip*. :) – endolith Apr 17 '13 at 13:38