Skip to content

Commit

Permalink
support 2^n Mhz clock frequencies
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdralph committed Aug 21, 2020
1 parent 3a761ad commit 412587c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ For example, the Blink example sketch built for the Uno takes 924 bytes of flash
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.

## Limitations
ArduinoShrink supports only ATmegax8 MCUs running at 16Mhz
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.

## Development plans
Future versions will support 8Mhz.
6 changes: 4 additions & 2 deletions src/wiring.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ extern void delay_impl();
void delay(uint32_t msec)
{
register uint32_t ms asm ("r24") = msec;
asm volatile (
asm ( ".equ T0CNT_PER_MS, %0\n"
".global T0CNT_PER_MS\n"
".equ T0CNT_PER_MS, 250\n"
// T0 prescaler is 64
:: "i" (F_CPU / 1000 / 64) );
asm volatile (
"rcall %x1\n"
: "+r"(ms)
: "i"(delay_impl)
Expand Down

0 comments on commit 412587c

Please sign in to comment.