I have a project that needs to run on 3.3V, SMD components. So using a TQFP adapter, I changed the boot loader on my Atmega328P-AU chip. Using Gammon's board programmer found here. I used an UNO as my programmer. I chose "L" to program it as a lillypad, 8mhz crystal. Since the chip already had the UNO boot loader on it, I used a 16mhz crystal in the setup when I burnt the new boot loader. It seemed to go fine.
So I switched the crystal out for an 8mhz one and uploaded a test sketch using the TX/RX lines. (choosing "Processor: Atmega328, (3V, 8MHZ)" in the arduino IDE.
It runs fine, but I noticed by chance that the sketch also works even if I remove the 8mhz crystal. I can upload sketches to it, also, without the crystal. Is this normal? (I should mention, I'm temporarily using a 5 volt FTDI to program and test it) It will be 3.3V in the end project.
I tried choosing "Processor: Atmega328, (5V, 16MHZ)" in the arduino IDE to load a sketch and it wouldn't work. So I guess my 8MHZ boot loader is installed.
Do I have anything to worry about? I'm wondering if it's maybe the boot loader I put on it makes it run without any crystal? The Lilliypad has one, though. (A resonator).
Atmega chip detector.
Written by Nick Gammon.
Version 1.20
Compiled on Jun 4 2017 at 23:13:09 with Arduino IDE 10613.
Attempting to enter ICSP programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x95 0x0F
Processor = ATmega328P
Flash memory size = 32768 bytes.
LFuse = 0xE2
HFuse = 0xDA
EFuse = 0xFD
Lock byte = 0xEF
Clock calibration = 0xAE
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 2048 bytes starting at 7800
Does that mean it's set up to use the 8Mhz crystal, and run at 3.3V?
Thanks.
Ok, I think I've found something here. In Gammon's sketch "Atmega Board Programmer " I found on line 417:
newlFuse = 0xE2; // internal 8 MHz oscillator
So I guess my chip is programmed to not use a crystal. My custom PCB has an 8Mhz crystal on it. Would I be better to use change this, or does it not matter. Pretty much the only thing the Atmega328P chip will be doing is communicating with aN NRF24L01 Transciever via SPI.
Should I re-burn a boot loader for an external chip? If so, do I just change that one line?
That board programmer sketch is useful for a very specific application where you want a self-contained programmer. If you don't need that capability then there's no point in using it.
I also recommend using MiniCore:
This will give you an extra 1.5 kB of program memory and allow you to do watchdog resets without going into the endless reset loop caused by a bug in the standard Lilypad bootloader.
SouthernAtHeart:
Can the Gammon board programmer sketch program it for 3.3V, external 8mhz crystal?
I don't want to mess it up by setting something wrong.
Thanks.
I found the answer to this after a few hours digging in the web:
change the one line in the "board programmer sketch" as follows. Comment out the line that's there, and add the one for external crystal
If you would have followed my advice and used MiniCore you could have just selected "8 MHz external" from the Tools > Clock menu, then did a Tools > Burn Bootloader but I'm sure it was an educational few hours.
I think the Lilypad is the only board among the official ones that uses the internal oscillator. What luck you have! If you had picked the Pro Mini bootloader everything would have worked (or not worked, as the case may be) as expected from the beginning.
Good thing it didn't. Now you've learned something.