FUSES

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello, i often set the fuses with the programmer(i use the ATMEL ICE), but i want to know if there is any form to set them in the code(in this moment and using the atmega328p), maybe using macros or something like that

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You cannot program fuses in your code

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not like program them. i refer like set them, but in the upper part of the program, before the int main and the libraries as example

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Charpie wrote:
Not like program them. i refer like set them,

Setting them is the same thing as programming them.

 

Let me put it this way....they are NOT settable/re-settable/changeable/readable/programmable via your code.

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Charpie wrote:
... maybe using macros or something like that
Either C or a pragma (instruction to the compiler)

Microchip AVR GCC :

#include <avr/io.h>

// Example data for ATxmega128A1
// The order of the fuse values is from low to high. 0xA2 is written to Fuse byte 0, 0x00 to byte 1...
const uint8_t fusedata[] __attribute__ ((section (".fuse"))) =
 {0xA2, 0x00, 0xFF, 0xFF, 0xFF, 0xF5};
 

Atmel Studio 7 (PDF)

[page 128, bottom]

3.2.7.7.1 Creating ELF Files for tinyAVR, megaAVR, and XMEGA devices

 

Microchip MPLAB XC8 for AVR :

XC8.book (PDF)

[page 53]

3.3.5 Configuration Bit Access

 

MicrochipDIRECT : IIRC, there's a configuration form that's required for AVR (the programmer likely isn't an Atmel-ICE)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@gchapman

 

I think the OP wants to be able to read/change the fuses in their code prior to running MAIN().  Not set up an ELF file to set things up during flash programming

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I understand that the OP simply wants to write the fuse settings in the code.
It is shown in fuse.h.

    #include <avr/io.h>

    FUSES = 
    {
        .low = LFUSE_DEFAULT,
        .high = (FUSE_BOOTSZ0 & FUSE_BOOTSZ1 & FUSE_EESAVE & FUSE_SPIEN & FUSE_JTAGEN),
        .extended = EFUSE_DEFAULT,
    };

    int main(void)
    {
        return 0;
    }

間違っていたらごめんなさい。

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I believe that fuses can only be changed(set/programmed what have you) in the BOOT section.  Meaning you can make changes using a bootloader, but not in your actual application, which is how I am reading the OP.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user