News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Changing fuse settings for Atmega 328P from DEFAULT

Started by mikejp56, April 10, 2024, 04:55:42 PM

Previous topic - Next topic

mikejp56

Hi All,
I am pretty new to CodeBlocks and Atmega 328P programming.
I have a simple code that blinks and LED and uses the default fuse settings for the 3 fuses in fuse.c. I would like to change the lfuse setting from 0x62 to 0xFF so I can use a crystal. How would I change ".low=LFUSE_DEFAULT" to use 0xFF? I have tried multiple things; .low=0xFF, etc. and I keep getting errors for the setting. I can change the lfuse setting in AVRDUDESS and AVRDude and the crystal setting works. I just cannot figure out the syntax for CodeBlocks.
By the way this is an awesome program for a non-programmer to learn on!
Thanks and regards.
mikejp56

Miguel Gimenez

Using Atmel Studio with the ATmega32U4 I just use this in main.c:
FUSES =
  {
  .low = (FUSE_SUT1 & FUSE_CKDIV8),
  .high = (FUSE_BOOTSZ0 & FUSE_BOOTSZ1 & FUSE_EESAVE & FUSE_SPIEN & FUSE_JTAGEN),
  .extended = (FUSE_BODLEVEL2 & FUSE_BODLEVEL1 & FUSE_BODLEVEL0)
  };

The 328 should be similar.

mikejp56

Hi Miguel,
Thanks for your response. Is there a document that shows the different settings for each fuse? As I said I am pretty new to AVR and I only have a limited supply of ICs. I don't want to brick them if I can avoid it!
Thanks again for your response!
Regards,
mikejp56

Miguel Gimenez

AVR programming is OT here.

Atmel datasheets are very complete, read the "Memory programming" section of your micro. Do not mess with lock bits.

mikejp56

Hi Miguel,
In which section would AVR programming not be OT?
And thanks again for the prompt response.
Regards,
mikejp56.

Miguel Gimenez

The "Embedded development" subforum is more suitable, but your question should receive more answers in an AVR-specific forum.

mikejp56

Hi Miguel,
Thanks, I'll post future questions like this in the Embedded Forum.