Author Topic: Changing fuse settings for Atmega 328P from DEFAULT  (Read 354 times)

Offline mikejp56

  • Multiple posting newcomer
  • *
  • Posts: 11
Changing fuse settings for Atmega 328P from DEFAULT
« on: April 10, 2024, 04:55:42 pm »
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

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1563
Re: Changing fuse settings for Atmega 328P from DEFAULT
« Reply #1 on: April 10, 2024, 06:06:15 pm »
Using Atmel Studio with the ATmega32U4 I just use this in main.c:
Code
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.

Offline mikejp56

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Changing fuse settings for Atmega 328P from DEFAULT
« Reply #2 on: April 10, 2024, 06:20:36 pm »
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

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1563
Re: Changing fuse settings for Atmega 328P from DEFAULT
« Reply #3 on: April 10, 2024, 08:01:04 pm »
AVR programming is OT here.

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

Offline mikejp56

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Changing fuse settings for Atmega 328P from DEFAULT
« Reply #4 on: April 10, 2024, 09:09:12 pm »
Hi Miguel,
In which section would AVR programming not be OT?
And thanks again for the prompt response.
Regards,
mikejp56.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1563
Re: Changing fuse settings for Atmega 328P from DEFAULT
« Reply #5 on: April 10, 2024, 10:05:59 pm »
The "Embedded development" subforum is more suitable, but your question should receive more answers in an AVR-specific forum.

Offline mikejp56

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Changing fuse settings for Atmega 328P from DEFAULT
« Reply #6 on: April 11, 2024, 01:34:03 am »
Hi Miguel,
Thanks, I'll post future questions like this in the Embedded Forum.