diff options
author | cpldcpu <cpldcpu@gmail.com> | 2015-05-30 18:39:45 +0200 |
---|---|---|
committer | cpldcpu <cpldcpu@gmail.com> | 2015-05-30 18:39:45 +0200 |
commit | 616f5810f1ba98f3f963e4e8b947ad3c6bd9ea57 (patch) | |
tree | cfab3078f83d8d6e52d91ad8d55939854863a7ae /firmware | |
parent | a7aa590a8965516ad0f0865be2c87b794127a8e0 (diff) | |
download | micronucleus-616f5810f1ba98f3f963e4e8b947ad3c6bd9ea57.tar.gz micronucleus-616f5810f1ba98f3f963e4e8b947ad3c6bd9ea57.tar.bz2 micronucleus-616f5810f1ba98f3f963e4e8b947ad3c6bd9ea57.zip |
firmware: added OSCCAL_SLOW_PROGRAMMING
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/configuration/Nanite841/Makefile.inc | 2 | ||||
-rw-r--r-- | firmware/configuration/Nanite841/bootloaderconfig.h | 5 | ||||
-rw-r--r-- | firmware/main.c | 14 |
3 files changed, 19 insertions, 2 deletions
diff --git a/firmware/configuration/Nanite841/Makefile.inc b/firmware/configuration/Nanite841/Makefile.inc index 9601a69..e147248 100644 --- a/firmware/configuration/Nanite841/Makefile.inc +++ b/firmware/configuration/Nanite841/Makefile.inc @@ -15,7 +15,7 @@ DEVICE = attiny841 # - for the size of your device (8kb = 1024 * 8 = 8192) subtract above value 2124... = 6068 # - How many pages in is that? 6068 / 64 (tiny85 page size in bytes) = 94.8125 # - round that down to 94 - our new bootloader address is 94 * 64 = 6016, in hex = 1780 -BOOTLOADER_ADDRESS = 19C0 +BOOTLOADER_ADDRESS = 1980 FUSEOPT = -U lfuse:w:0xe2:m -U hfuse:w:0xdd:m -U efuse:w:0xfe:m FUSEOPT_DISABLERESET = # TODO diff --git a/firmware/configuration/Nanite841/bootloaderconfig.h b/firmware/configuration/Nanite841/bootloaderconfig.h index 20be3f6..5812ace 100644 --- a/firmware/configuration/Nanite841/bootloaderconfig.h +++ b/firmware/configuration/Nanite841/bootloaderconfig.h @@ -190,6 +190,10 @@ * will be made to calibrate the oscillator. You should deactivate both options above * if you use this to avoid redundant code. * + * OSCCAL_SLOW_PROGRAMMING Setting this to '1' will set OSCCAL back to the factory calibration during programming to make + * sure correct timing is used for the flash writes. This is needed if the micronucleus clock + * speed significantly deviated from the default clock. E.g. 12 Mhz on ATtiny841 vs. 8Mhz default. + * * If both options are selected, OSCCAL_RESTORE_DEFAULT takes precedence. * * If no option is selected, OSCCAL will be left untouched and stays at either factory calibration or F_CPU depending @@ -200,6 +204,7 @@ #define OSCCAL_RESTORE_DEFAULT 1 #define OSCCAL_SAVE_CALIB 1 #define OSCCAL_HAVE_XTAL 0 +#define OSCCAL_SLOW_PROGRAMMING 1 /* * Defines handling of an indicator LED while the bootloader is active. diff --git a/firmware/main.c b/firmware/main.c index a6bb8c6..fdf22e4 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -229,6 +229,8 @@ static inline void leaveBootloader(void) { void USB_INTR_VECTOR(void); int main(void) { + uint8_t osccal_tmp; + bootLoaderInit(); /* save default OSCCAL calibration */ @@ -286,12 +288,22 @@ int main(void) { } while(--fastctr); wdr(); - + + #if OSCCAL_SLOW_PROGRAMMING + osccal_tmp = OSCCAL; + OSCCAL = osccal_default; + #endif // commands are only evaluated after next USB transmission or after 5 ms passed if (command==cmd_erase_application) eraseApplication(); if (command==cmd_write_page) writeFlashPage(); + #if OSCCAL_SLOW_PROGRAMMING + OSCCAL = osccal_tmp; + #endif + + + if (command==cmd_exit) { if (!fastctr) break; // Only exit after 5 ms timeout } else { |