diff options
author | Bluebie <a@creativepony.com> | 2013-03-04 13:07:45 +1100 |
---|---|---|
committer | Bluebie <a@creativepony.com> | 2013-03-04 13:07:45 +1100 |
commit | d5788624c23c1794c732401e1a4807366ed8a166 (patch) | |
tree | d3e0f473f31e23d2c325fdc7b215f1d339f740ec /firmware/main.c | |
parent | 3d75771c55db65d3f1869c4d81e959f4b27eeb4a (diff) | |
download | micronucleus-d5788624c23c1794c732401e1a4807366ed8a166.tar.gz micronucleus-d5788624c23c1794c732401e1a4807366ed8a166.tar.bz2 micronucleus-d5788624c23c1794c732401e1a4807366ed8a166.zip |
Firmware & Upgrade: Released 1.06! yet to add -jumper release tho. Fixes clock speed thing - always starts at 16.5mhz now!
Diffstat (limited to 'firmware/main.c')
-rw-r--r-- | firmware/main.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/firmware/main.c b/firmware/main.c index 708f474..0db320c 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -10,7 +10,7 @@ */ #define MICRONUCLEUS_VERSION_MAJOR 1 -#define MICRONUCLEUS_VERSION_MINOR 5 +#define MICRONUCLEUS_VERSION_MINOR 6 // how many milliseconds should host wait till it sends another erase or write? // needs to be above 4.5 (and a whole integer) as avr freezes for 4.5ms #define MICRONUCLEUS_WRITE_SLEEP 8 @@ -368,6 +368,17 @@ static inline void leaveBootloader(void) { // clear magic word from bottom of stack before jumping to the app *(uint8_t*)(RAMEND) = 0x00; *(uint8_t*)(RAMEND-1) = 0x00; + + // adjust clock to previous calibration value, so user program always starts with same calibration + // as when it was uploaded originally + // TODO: Test this and find out, do we need the +1 offset? + unsigned char stored_osc_calibration = pgm_read_byte(BOOTLOADER_ADDRESS - TINYVECTOR_OSCCAL_OFFSET); + if (stored_osc_calibration != 0xFF && stored_osc_calibration != 0x00) { + //OSCCAL = stored_osc_calibration; // this should really be a gradual change, but maybe it's alright anyway? + // do the gradual change - failed to score extra free bytes anyway in 1.06 + while (OSCCAL > stored_osc_calibration) OSCCAL--; + while (OSCCAL < stored_osc_calibration) OSCCAL++; + } // jump to application reset vector at end of flash asm volatile ("rjmp __vectors - 4"); @@ -382,11 +393,6 @@ int main(void) { uint8_t prescaler_default = CLKPR; #endif - unsigned char stored_osc_calibration = pgm_read_byte(BOOTLOADER_ADDRESS - TINYVECTOR_OSCCAL_OFFSET + 1); - if (stored_osc_calibration != 0xFF) { - OSCCAL = stored_osc_calibration; - } - wdt_disable(); /* main app may have enabled watchdog */ tiny85FlashInit(); bootLoaderInit(); |