Author Topic: Questions about fuses, clockrate and timers  (Read 1317 times)

Greengnu

  • Newbie
  • *
  • Posts: 1
Questions about fuses, clockrate and timers
« on: May 14, 2019, 02:31:43 pm »
So far I managed to recompile bootloader to disable 5 seconds delay and create an upgrade firmware with it and loaded it onto my digispark through Micronucleus.
I also managed to disable reset fuse using isp programming and to get my arduino sketches running on the board.

Now I’m wondering about running the digispark at 1Mhz for low power consumption and have a couple of questions:

1. Boardselection in Arduino IDE:
In the arduino IDE I can chose between 1Mhz, 8Mhz and 16Mhz versions. Am I correct to assume that this selection does not actually change the clockspeed of my digispark and instead a mismatching selection simply causes delays being incorrect?

2. How can I verify at what clockspeed my digispark is actually running?

3. One way to change the clockspeed through code seems to be to set the prescaler like so:
#include <avr/power.h>
    void setup()
    {
        clock_prescale_set(clock_div_8);
    }
Am I correct to assume that in this case the bootloader will still run at 16mhz and running it at low voltage may throw it in a reboot cycle?

4. If changing thr clockrate like in 3., how does this affect interrupt timers? Especially in regards to timer prescalers. The attiny datasheet (https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf) on page 89 describes the prescalers for the timer - but what is the actual system clock this prescaler is applied to? Is it 16Mhz in any case, or is it 16mhz divided by the vlock prescaler as set in 3.?

5. Does the bootloader actually set the system clockrate?

6. What is the correct avrdude command to set the digispark fuses such that it runs at 1Mhz?

7. besides the two options (A:setting prescaler through code B: setting fuses with ISP programmer and avrdude) is there any other option to change the clockrate?