Skip to content

Commit 412587c

Browse files
committed
support 2^n Mhz clock frequencies
1 parent 3a761ad commit 412587c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ For example, the Blink example sketch built for the Uno takes 924 bytes of flash
66
Download [a release](https://github.com/nerdralph/ArduinoShrink/releases), and extract the files into your Arduino/libraries folder. Select ArduinoShrink from the Sketch, Include Library menu. This will replace several Arduino functions with smaller and faster versions. The Arduino pin number must be known at compile time if you are using this library.
77

88
## Limitations
9-
ArduinoShrink supports only ATmegax8 MCUs running at 16Mhz
9+
ArduinoShrink supports only ATmega8 and ATmegax8 MCUs. Accurate timing for millis() and delay() requires a freqquency that is a power of two such as 1Mz, 8Mhz, or 16Mhz.
1010

11-
## Development plans
12-
Future versions will support 8Mhz.

src/wiring.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ extern void delay_impl();
99
void delay(uint32_t msec)
1010
{
1111
register uint32_t ms asm ("r24") = msec;
12-
asm volatile (
12+
asm ( ".equ T0CNT_PER_MS, %0\n"
1313
".global T0CNT_PER_MS\n"
14-
".equ T0CNT_PER_MS, 250\n"
14+
// T0 prescaler is 64
15+
:: "i" (F_CPU / 1000 / 64) );
16+
asm volatile (
1517
"rcall %x1\n"
1618
: "+r"(ms)
1719
: "i"(delay_impl)

0 commit comments

Comments
 (0)