1

I have build a couple of boards that have an ATMEGA328P-AU (the 32 pin MLF, as used on the Arduino Pro Mini). If I burn a bootloader via SPI to use an external 8MHz clock, I can then use the Arduino IDE to write a program via the serial port. If I burn a bootloader to use an internal 8MHz clock, burning the bootloader is still successful but programming with the Arduino IDE does not work.

The current boards do have crystals, but I want to build the rest of the boards without a crystal, so I need to get internal clock working.

The internal (non-working) script looks like this:

avrdude -Cavrdude.conf -v -patmega328p -B4 -cusbasp -Pusb -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xE2:m
avrdude -Cavrdude.conf -c usbasp -p atmega328p -e -Uflash:w:ATmegaBOOT_168_atmega328_pro_8MHz.hex

The external (working) script looks like this:

avrdude -Cavrdude.conf -v -patmega328p -B4 -cusbasp -Pusb -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m
avrdude -Cavrdude.conf -c usbasp -p atmega328p -e -Uflash:w:ATmegaBOOT_168_atmega328_pro_8MHz.hex

By my reckoning, lfuse=0xE2 should be CKDIV8=1, CKOUT=1, SUT=10 and CKSEL=0010.

Any suggestions how to make the internal clock work?

3
  • Except for the clock division bit I never set any fuses and it works for me. For a test you could try without setting any fuses, the atmegas are set to run with the internal clock by default from my experience. Commented Feb 13, 2021 at 9:49
  • Use ISP programmer, file menu >> Sketch >> Upload using programmer, to upload the sketch instead of via UART (arduino bootloader) and completely ignore the bootloader thing. You have to choose correct programmer, file menu >> Tools >> Programmer. I suppose you spin your own pcb then pop out an ISP port is no problem. Just be aware that timing stuffs, like delay and all, would not work correctly. also you would run into trouble with UART as well. But I think add a small resonator like CSTNE16M0V51Z000R0 on PCB wouldn't be a problem since it's quite darn small and not that expensive. Commented Feb 13, 2021 at 9:53
  • Are you trying to program over serial? Serial requires a somewhat accurate clock. Maybe the RC-oscilator is to far of 8Mhz for serial to work. Can you upload a blink sketch over ISP, and have it blink with those fuse settings? Commented Feb 13, 2021 at 16:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.