You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: megaavr/extras/Ref_Clocks.md
+17-14Lines changed: 17 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,17 +2,18 @@
2
2
This section seeks to cover information about the clocking options on the tinyAVR parts at somewhat greater depth than a simple list of supported options.
3
3
Be aware that this is very different from the equivalent document for the Dx and Ex-series. The oscillators are very different.
4
4
5
-
**Crystal** is not supported as a clock source on the DA-series, or EB-series, but is on the DB, DD, and DU-series.
5
+
## Overview
6
+
The modern AVRs have been released with, effectively, three different systems for the clock generation.
6
7
7
-
##Background - how the timers work
8
-
see also [the timer reference](Ref_Timer.md)
8
+
### On tinyAVR
9
+
The OSCCFG fuse selects whether the speed is derived from a 20 MHz or 16 MHz oscillator. At power-on, these are always set to a prescaler of /6 hence 2.66 or 3.33 MHz. The core, prior to calling setup, will reconfigure the prescaler to match the requested speed. The OSCCFG fuse is always set when a sketch is uploaded via a UPDI programmer using megaTinyCore, however it cannot be set using the bootloader. These parts can't use an external HF crystal, only an external *clock*.
9
10
10
-
### On tinyAVR and Ex-series
11
-
The OSCCFG fuse selects whether the speed is derived from a 20 MHz or 16 MHz oscillator. At power-on, these are always set to a prescaler of /6 hence 2.66 or 3.33 MHz. The core, prior to calling setup, will reconfigure the prescaler to match the requested speed. The OSCCFG fuse is always set when a sketch is uploaded via a UPDI programmer.
12
-
They additionally have the equivalent of the classic AVR's OSCCAL calibration register, and like those parts, the compliance is many times what the datasheet claims, and you can get a very wide range of speeds from them. 0/1-series has 64 settings for each nominal clock frequency, and 2-series parts have 128. Determining the value to set it to in order to obtain a desired clock speed is called "Tuning", even though you're not doing it for accuracy (it's generally already at the best setting from factory cal if you want the nominal clock speed.)
11
+
They additionally have the equivalent of the classic AVR's OSCCAL calibration register, and like those parts, the compliance is many times what the datasheet claims, and you can get a very wide range of speeds from them. 0/1-series has 64 settings for each nominal clock frequency, and 2-series parts have 128. At a range of clock speeds (12-24 on the main clock on most parts), both oscillators could be tuned to output the desired clock.
12
+
13
+
I suspect that the classic AVR oscillator withthe 8-bit OSCCAL register that was bifurcated in the middle is a very similar mechanism. Note that while the ranges overlap,
13
14
14
15
### On Dx-series
15
-
Fuses only control whether it starts up at 4 MHz or 32 kHz (we don't support the latter). Code that runs very early in the sketch (before start() but after the dirty reset check and after the clears initializers) serves to initialize the peripherals, including clkctrl to their requested settings.
16
+
Fuses only control whether it starts up at 4 MHz or 32 kHz (the latter is unsupported as a clock source . Code that runs very early in the sketch (before start() but after the dirty reset check and after the clears initializers) serves to initialize the peripherals, including clkctrl to their requested settings.
16
17
17
18
The OSCCTRL.OSCHFCTRLA register's *middle* 4 bits control the frequency of the internal oscillator. This field divides neatly into two sections. 0x0, 0x1, 0x2 and 0x3 are 1, 2, 3, and 4 MHz. The next one is reserved (I'd wager it would give 4 MHz). That's followed by the next section, 8, and every subsequent multiple of 4 up to 24 are listed in the datasheet, and at least at room temperature, extending the pattern 2 more rungs is consistent, and leads to speeds of 28 and 32 MHz, generally work at room temperature. (beyond that, the last 4 are repeated).
18
19
@@ -40,7 +41,9 @@ Tuning to achieve non-standard speeds is not supported on the AVR Ex-series part
40
41
## Supported Clock Speeds
41
42
Like classic AVRs, tinyAVRs have a "speed grades" depending on the voltage and operating conditions that they are rated for operation within. The spec is 5 MHz @ 1.8V , 10 MHz @ 2.7V (3.3V nominal) and 20 @ 4.5V (5.0V nominal) (2.7 or 4.5 for 8MHz and 16 MHz at >105C . See the Speed Grade reference for more information on this. Note that the speed grades are extremely conservative for room temperature operation, and unreal overclocking is easily achievable at room temperaturee, particularly with high temp. rated parts.
42
43
43
-
The AVR Dx-series come in I (105C) and E (125C) spec parts. Since the DA-series was released, Microchip has STOPPED MARKING THE SPEED GRADE ON THE CHIPS. Be sure that if you have both speed grades, you mark the chips somehow (0 and 1-series parts do still have the temperature rating marked (N = 105, F = 125).
44
+
The AVR Dx-series come in I and E spec parts.
45
+
46
+
Since the DA-series was released, Microchip has STOPPED MARKING THE SPEED GRADE ON THE CHIPS. Be sure that if you have both speed grades, you mark the chips somehow (0 and 1-series parts do still have the temperature rating marked (N = 105, F = 125).
44
47
45
48
46
49
Some of the listed speeds, while supported by the hardware are not supported by the core - typically weird, slow clocks, particularly from a crystal
@@ -50,12 +53,12 @@ For unsupported speeds, the micros and delay-us columns indicate what internal p
0 commit comments