I have just put ATMega328P-AU (brand new - no bootloader, no program) on PCB, added 16 MHz crystal, ISP header and successfully programmed "blink" example it using AVRISP mkII (used Uno and Duemillanove 328 board profiles). To my surprise LED blink frequency was very small. Using stopwatch I came to conclusion that 328 is running at 1 MHz instead of expected 16 Mhz.
I searched this forum but could not find the answer. Found traces lead to fuse settings.
Please, does anybody know what is wrong and how to fix it - to get 16 MHz?
Thanks so far. So, I created a new section in boards.txt for testing, selected it in IDE, and used fuse calculator from your link. According to 328 manual, CKSEL3..0 for external crystal should be from 1111 to 1010. I tried to set bootloader.low_fuses from F0 to FF with different SUT setting as well. After each change in boards.txt I reopened IDE and reload the Blink sketch. No change - stil working on low frequency.
Any other idea on the cause? What else to check? Thanks.
Command line. avrdude. For example, this reads the EEPROM from an ATtiny13 and saves the contents into a file named dump.txt ...
avrdude -p attiny13 -c stk500v1 -P \.\COM14 -b 57600 -U eeprom:r:dump.txt:h
Changing fuses is like building fine furniture. One wrong move and the piece is ruined.
First get comfortable reading the fuses from the targetA. Then get comfortable writing to FlashA. Next determine exactly what the fuses should be. RepeatB. If you get the fuses wrong the processor can be left in a state where only a "high voltage" programmer can resurrect it. Finally, change the fusesC.
Continuing with the woodworking analogy...
A Practice using the tool. B Measure twice. C Cut once.
I have just put ATMega328P-AU (brand new - no bootloader, no program) on PCB, added 16 MHz crystal, ISP header and successfully programmed "blink" example it using AVRISP mkII (used Uno and Duemillanove 328 board profiles). To my surprise LED blink frequency was very small. Using stopwatch I came to conclusion that 328 is running at 1 MHz instead of expected 16 Mhz.
The solution I use is first burn the standard bootloader, then upload your program (whether or not it uses the bootloader).
I am sure. I changed both "delay(1000);" statements in Blink sketch to 100 ms. Turn on/off LED cycle is hence 200 ms. Ten cycles give 2 seconds. After uploading the sketch it took about 31 seconds for LED to do 10 cycles. 31 s / 2 s "=" 16
I read your last post after I did procedure below. I do not know what were default factory settings for fuses. I can check them in my next project with another blank 328.
John_S:
The solution I use is first burn the standard bootloader, then upload your program (whether or not it uses the bootloader).
Thanks John. That was my last option if everything else fails.
Gentlemen, I made it working with your great help. Solution: