|
3 | 3 |
|
4 | 4 | This repo contains the Arduino corefiles used with [MightyCore](https://github.com/MCUdude/MightyCore), [MegaCore](https://github.com/MCUdude/MegaCore), [MiniCore](https://github.com/MCUdude/MiniCore) and [MajorCore](https://github.com/MCUdude/MightyCore).
|
5 | 5 |
|
| 6 | + |
6 | 7 | ## Supported devices
|
| 8 | + |
7 | 9 | * ATmega640, ATmega1280, ATmega2560
|
8 | 10 | * ATmega64, ATmega128, ATmega1281, ATmega2561
|
9 | 11 | * AT90CAN32, AT90CAN64, AT90CAN128
|
10 | 12 | * ATmega8535, ATmega16, ATmega32, ATmega164A/P, ATmega324A/P/PA/PB, ATmega644/P, ATmega1284/P
|
11 | 13 | * ATmega8515, ATmega162
|
12 | 14 | * ATmega8, ATmega48/P/PA/PB, ATmega88/P/PA/PB, ATmega168/P/PA/PB, ATmega328/P/PA/PB
|
13 | 15 |
|
| 16 | + |
14 | 17 | ## Supported clock frequencies
|
15 |
| -By supported I mean clocks that accurate timing is implemented for (millis, micros, delay, delayMicroseconds). |
| 18 | + |
| 19 | +By supported I mean clocks that accurate timing is implemented for (millis, |
| 20 | +micros, delay, delayMicroseconds). |
| 21 | + |
16 | 22 | * 32 MHz
|
| 23 | +* 25 MHz |
17 | 24 | * 24 MHz
|
| 25 | +* 22.1184 MHz |
18 | 26 | * 20 MHz
|
19 | 27 | * 18.432 MHz
|
| 28 | +* 18 MHz |
| 29 | +* 16.5 MHz |
20 | 30 | * 16 MHz
|
21 | 31 | * 14.7456 MHz
|
22 | 32 | * 12 MHz
|
23 | 33 | * 11.0592 MHz
|
| 34 | +* 10 MHz |
| 35 | +* 9.216 MHz |
24 | 36 | * 8 MHz
|
25 | 37 | * 7.3728 MHz
|
| 38 | +* 6 MHz |
26 | 39 | * 4 MHz
|
27 | 40 | * 3.6864 MHz
|
28 | 41 | * 2 MHz
|
29 | 42 | * 1.8432 MHz
|
30 | 43 | * 1 MHz
|
| 44 | + |
| 45 | + |
| 46 | +### Adding further clock frequencies |
| 47 | + |
| 48 | +The calculation of `millis()`, `micros()` and `delay()` is automatic for |
| 49 | +arbitrary frequencies. |
| 50 | +Depending on the prime factors of the frequency, it is either exact or |
| 51 | +approximate to 60 ppm accuracy (worst-case). |
| 52 | +The only thing required is adding support in `delayMicroseconds()`. |
| 53 | + |
| 54 | + |
| 55 | +### Exactness of `delayMicroseconds()` |
| 56 | + |
| 57 | +The `delayMicroseconds(unsigned int us)` implementation is exact up to a few |
| 58 | +cycles for the frequencies listed above. |
| 59 | + |
| 60 | +The maximum input parameter to work reliably is 10000 for 10 milliseconds. |
| 61 | +Its result is affected by interrupts occurring, which may prolong the delay. |
| 62 | + |
| 63 | + |
| 64 | +### Exactness of `micros()` and `delay()` |
| 65 | + |
| 66 | +For the clock speeds listed above, `micros()` is corrected to zero drift. |
| 67 | +Even for very long run times, the `micros()` function will precisely follow the |
| 68 | +oscillator used. |
| 69 | + |
| 70 | +Frequencies not listed above are either exact or corrected to below 60 ppm drift |
| 71 | +and in exact sync with `millis()`. |
| 72 | + |
| 73 | +Note that the result of `micros()` may jump up by several microseconds between |
| 74 | +consecutive calls and rolls over after one hour and eleven minutes. |
| 75 | + |
| 76 | +The `delay()` function uses `micros()` internally and inherits its drift accuracy |
| 77 | +with slight variations due to function call overhead and processing. |
| 78 | +It is immune to interrupts and thus long-term accurate. |
| 79 | + |
| 80 | + |
| 81 | +### Exactness of `millis()` |
| 82 | + |
| 83 | +For the clock speeds listed above, `millis()` is corrected to zero drift. |
| 84 | +Even for very long run times, the `millis()` function will precisely follow the |
| 85 | +oscillator used. |
| 86 | + |
| 87 | +Frequencies not listed above are either exact or corrected to below 60 ppm drift |
| 88 | +and in exact sync with `micros()` and `delay()`. |
| 89 | + |
| 90 | +We do not register the rollover of the `unsigned long` millis counter that |
| 91 | +occurs every 49.7 days; such would have to be done in the user's program. |
| 92 | +Often this is not necessary: The code |
| 93 | + |
| 94 | + if (millis() - millis_old >= interval) { |
| 95 | + /* do something */ |
| 96 | + millis_old += interval; |
| 97 | + } |
| 98 | + |
| 99 | +is long-term accurate even when rolling over provided `millis_old` is of type |
| 100 | +`unsigned long`. |
| 101 | + |
| 102 | +For clock speeds of 16 MHz and below, the return value of `millis()` |
| 103 | +occasionally jumps up by more than one (notwithstanding low/zero drift). |
| 104 | +Thus, when relying on consecutive returns, run at 16.5 MHz or higher. |
0 commit comments