NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » power management on the AVR

December 21, 2016
by jvanderspek
jvanderspek's Avatar

I wrote a multithreading kernel (and adapted the lcd software to be reentrant), and got a bit stuck in attempting to do good power management, particularly getting to an efficient sleep mode when all threads are idle. Which in 'typical' apps they usually are. I have a couple of questions related to this that I hope someone can help me with:

1) I use timer#0 for time slicing and thread sleeping. #0 is driven by CLKio, which is disabled in all but sleep mode idle, see page 39 of the ATmega manual. It even seems to be disabled in ADC noise reduction mode, which makes this setup less useful because this causes me to lose global wall clock time when actually reducing ADC noise.

Now barring an external clock, there is also CLKasy, which can be driven by a 32 kHz external crystal. But because the XTAL and TOSC pins are shared this seems to force me to use the internal oscillator as clock source, running at most 8 MHz (pag 33), about half of what I am running now. I have the impression I am missing something, does anyone have a suggestions?

2) Using the low power crystal oscillator consumes the least amount of power, but is "not capable of driving other clock inputs" (pag 28 of the ATmega manual). What exactly are these "other" inputs that can't be driven? Inputs to chips other than the AVR processor? In other words, when using a low power crystal, will my standalone atmega328p be fully functional?

3) The Nerdkit came with a 14.x MHz crystal, and according to Chapter 8 of the ATmega manual we need capacitors C1 and C2 that do not occur on the schematics for the different Nerkkit projects. What is the effect exactly of omitting them?

4) The standard Nerdkits cable via the boot loader does not allow reading (or writing) the fuse bits. Does anyone know the fuse bit settings programmed on the processors that came from NerdKits? (I am currently unable to read them).

Thanks a lot,

Juul

December 25, 2016
by lnino
lnino's Avatar

Hi jvanderspek,

sadly I am not very familiar with energy saving.

I have only used the watchdog for reactive light in a geocaching Project.

But I can help you with point 3 and 4.

Answer to point 3: For the 14.x Mhz crystal you need two 22pF capacitors so the crystal is able to oscilate. Maybe it works on a breadboard without capacitors, but on a PCB you might get in troubles without them. So put them in every project as Standard. The Nerdkit itself is really puristic. Normally you would also need 2 pieces 100nF capicitors for the 7805 to protect them and keep it stable.

Answer to point 4: The fuses of the nerdkit tutorial Looks like that:

atmega8:
    low fuse byte:
        clock-source external xtal: CHKSEL = 0

    -> default: 0xe1
       new:     0b11100000 = 0xe0

    high fuse byte:
        512 words bootloader size: BOOTSZ0 = 1
                                   BOOTSZ1 = 0

        reset vector, jump to bootloader on reset: BOOTRST = 0

        no eeprom erase on chip erase: EESAVE = 0

    -> default: 0b11011001 = 0xd9
       new:     0b11010010 = 0xd2

    lock byte:
        SPM is not allowed to write to the Boot Loader section BLB12 = 1
                                                               BLB11 = 0

    -> default: 0b111111 = 0x3f
       new:     0b101111 = 0x2f

atmega88/168:
    low fuse byte:
        clock-source external xtal: CHKSEL = 0

        disable system clock divide by 8: CKDIV8 = 1

    -> default: 0b01100010 = 0x62
       new:     0b11100000 = 0xe0

    high fuse byte:
        no eeprom erase on chip erase: EESAVE = 0

    -> default: 0b11011111 = 0xdf
       new:     0b11010111 = 0xd7

    extended fuse byte:
        512 words bootloader size: BOOTSZ0 = 1
                                   BOOTSZ1 = 0

        OR:
        1024 words bootloader size: BOOTSZ0 = 0
                                    BOOTSZ1 = 0

        reset vector, jump to bootloader on reset: BOOTRST = 0

    -> default: 0b001 = 0x01
       new:     0b010 = 0x02 OR 0x00

    lock byte:
        SPM is not allowed to write to the Boot Loader section BLB12 = 1
                                                               BLB11 = 0

    -> default: 0b111111 = 0x3f
       new:     0b101111 = 0x2f

atmega32:
    high fuse byte
        - enable jtag unprogram: JTAGEN = 1
        - bootloader size 512 words: BOOTSZ1 = 1
                                     BOOTSZ0 = 0
        - jump to bootloader: BOORST = 0

    ->  default: 0b10011001 = 0x99
        neu:     0b11011100 = 0xdc

    low fuse byte:
        - external crystal clock, fast rising power: CKSEL = 1111

    ->  default: 0b11100001 = 0xe1
        neu:     0b11101111 = 0xef

    lock byte:
        SPM is not allowed to write to the Boot Loader section BLB12 = 1
                                                               BLB11 = 0

    -> default: 0b111111 = 0x3f
       new:     0b101111 = 0x2f

atmega644:
    high fuse byte

        - enable jtag unprogram: JTAGEN = 1
        - bootloader size 1024 words: BOOTSZ1 = 1
                                      BOOTSZ0 = 0
        - jump to bootloader: BOORST = 0

    ->  default: 0b10011001 = 0x99
        neu:     0b11011100 = 0xdc

    low fuse byte:

        - external crystal clock, fast rising power: CKSEL3..0 = 0111
                                                     SUT1..0 = 10
        - (unprogram) CKDIV8 = 1

    ->  default: 0b01100010 = 0x62
        neu:     0b11100111 = 0xe7

    lock byte:
        SPM is not allowed to write to the Boot Loader section BLB12 = 1
                                                               BLB11 = 0

    -> default: 0b111111 = 0x3f
       new:     0b101111 = 0x2f

The modified fuses by mike are like this:

EFUSE = 0x00
0   -
0   -
0   -
0   -
0   -
0   BOOTSZ1 (1024 word boot size)
0   BOOTSZ0     ""
0   BOOTRST (jump to bootloader)

HFUSE = 0xd5
1   RSTDISBL
1   DWEN
0   SPIEN
1   WDTON
0   EESAVE
1   BODLEVEL2   (sets V_BOT=2.7)
0   BODLEVEL1       ""
1   BODLEVEL0       ""

LFUSE = 0xf7
1   CKDIV8
1   CKOUT
1   SUT1    (65ms start-up delay)
1   SUT0        ""
0   CKSEL3  (full swing crystal oscillator)
1   CKSEL2      ""
1   CKSEL1      ""
1   CKSEL0      ""

LOCK = 0x2f
0   -
0   -
1   BLB12   (can't self-program over bootloader)
0   BLB11       ""
1   BLB02   (no restrictions on programming application code area)
1   BLB01       ""
1   LB2 (no memory lock)
1   LB1     ""

Hopefully my answers are helpful for you.

If you have any further questions please let me know.

greetings Nino

December 25, 2016
by jvanderspek
jvanderspek's Avatar

Hi Nino,

Thanks for your extensive answer. Yes, it helped me.

Juul

Post a Reply

Please log in to post a reply.

Did you know that negative numbers are represented in two's complement notation in binary? Learn more...