From 745d73b98aab4f73d5e7895dd4da5eaafa7e13d4 Mon Sep 17 00:00:00 2001 From: Andrew Makousky Date: Thu, 17 Sep 2020 02:46:49 -0500 Subject: [PATCH] RTC: Program fuse bits from C source. --- firmware/rtc/MacRTC.c | 13 +++++++++++++ firmware/rtc/README.md | 14 +++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/firmware/rtc/MacRTC.c b/firmware/rtc/MacRTC.c index 0c2c423..97fc836 100644 --- a/firmware/rtc/MacRTC.c +++ b/firmware/rtc/MacRTC.c @@ -34,6 +34,19 @@ #include #include +/* Fuse bit programming. */ +#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || \ + defined(__AVR_ATtiny85__) +FUSES = { + // Use 8 MHz internal clock, not default 1 MHz internal clock. + .low = (LFUSE_DEFAULT | ~FUSE_CKDIV8), + // Disable the external RESET pin since it is used for the 1-second + // interrupt output. + .high = (HFUSE_DEFAULT & FUSE_RSTDISBL), + .extended = EFUSE_DEFAULT, +}; +#endif + /********************************************************************/ // Simplified Arduino.h definitions. typedef enum { false, true } bool; // Compatibility with C++. diff --git a/firmware/rtc/README.md b/firmware/rtc/README.md index 54093c1..a07edf9 100644 --- a/firmware/rtc/README.md +++ b/firmware/rtc/README.md @@ -9,11 +9,19 @@ unfortunately cannot be used (efficiently/effectively) by the ATTiny85. The AVR core clock is run from an internal oscillator to generate 8 -MHz, so set the fuse bits accordingly when programming. See the -source code of MacRTC.c for more information on electrical -specifications and the like. +MHz. The required fuse bytes setting is included in the generated ELF +object file in the `.fuse` section, in the order (low, high, +extended). See the source code of MacRTC.c for more information on +electrical specifications and the like. Reference source, Visited 2020-08-05: * https://www.reddit.com/r/VintageApple/comments/91e5cf/couldnt_find_a_replacement_for_the_rtcpram_chip/e2xqq60/ * https://pastebin.com/baPZ4nN4 + +## Device Programming + +Please note: For the ATTiny85 form factor, the external RESET pin must +be disabled since it is used for the 1-second interrupt output. +Therefore, after the initial programming, it will only be possible to +reprogram via high-voltage serial programming.