With too many Pro Mini with 8MHz crystal lying around here, I am replacing these crystals with a 16MHz crystal.
All original 8MHz Pro Minis can be uploaded to, showing 30k memory, indicative of the old original Pro Mini bootloader.
Crystal type: CSTCE16M
After installing the new crystal, no more uploading is possible. Only after re-installing the old original bootloader (over SPI) can there be new uploads (and 30k program space).
Obviously also the Optiboot bootloader can be installed (using the MiniCore from McDude for example), and the uploads work too (giving 32k of program space).
Why can a 8MHz crystal not be simply replaced by a (same form factor) 16MHz crystal, without having to reinstall the bootloader?
When the microcontroller is running at twice the speed, you need to double the upload baud rate speed. If the 8 MHz bootloader communicates at 57600 baud, it will communicate at 115200 baud when running at 16 MHz.
But isn't the standard 16MHz upload speed not 115200 baud anyway? So, when selecting the 16MHz board definition, the uploader speed is set at 115200 baud, and since the uC is now running at 16MHz, then that shouldn't that correspond?
Not sure about that, but i am pretty sure you need to set the fuses to the corresponding clock frequency regardless, and that gets done when burning the bootlaoder.
That is an interesting observation. But as can be seen from the added Pro Mini schematic, Vcc goes directly to the Vcc µC pins 18, 4 and 6.
And since I use the Pro Mini PCB pin that is connected to Vcc, 5V is directly sent to the controller Vcc pins, bypassing the regulator (which is only used when the PCB RAW pin is used).
But my initial question about the crystal change issue remains unanswered?
If the Pro Mini board type with 5V 16MHz is used, then of course the upload speed will be 115200. Yet this corresponds with the actual processor running at 16MHz.
And yet uploading after the crystal change only seems to work after reloading the bootloader. Why?
## Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328P
## --------------------------------------------------
pro.menu.cpu.16MHzatmega328=ATmega328P (5V, 16 MHz)
pro.menu.cpu.16MHzatmega328.upload.maximum_size=30720
pro.menu.cpu.16MHzatmega328.upload.maximum_data_size=2048
pro.menu.cpu.16MHzatmega328.upload.speed=57600
pro.menu.cpu.16MHzatmega328.bootloader.low_fuses=0xFF
pro.menu.cpu.16MHzatmega328.bootloader.high_fuses=0xDA
pro.menu.cpu.16MHzatmega328.bootloader.extended_fuses=0xFD
pro.menu.cpu.16MHzatmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex
pro.menu.cpu.16MHzatmega328.build.mcu=atmega328p
pro.menu.cpu.16MHzatmega328.build.f_cpu=16000000L
## Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328P
## ---------------------------------------------------
pro.menu.cpu.8MHzatmega328=ATmega328P (3.3V, 8 MHz)
pro.menu.cpu.8MHzatmega328.upload.maximum_size=30720
pro.menu.cpu.8MHzatmega328.upload.maximum_data_size=2048
pro.menu.cpu.8MHzatmega328.upload.speed=57600
pro.menu.cpu.8MHzatmega328.bootloader.low_fuses=0xFF
pro.menu.cpu.8MHzatmega328.bootloader.high_fuses=0xDA
pro.menu.cpu.8MHzatmega328.bootloader.extended_fuses=0xFD
pro.menu.cpu.8MHzatmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex
pro.menu.cpu.8MHzatmega328.build.mcu=atmega328p
pro.menu.cpu.8MHzatmega328.build.f_cpu=8000000L
the same upload speed as far as the IDE is concerned, but with a different crystal, the settings would therefore not be correct anymore as was stated already in reply #2 This is the basic issue that you want to solve and for that you need to burn the bootloader again, which includes the calculation for the baud-rate depending on the Clock-speed.
Eh yeah, but you are applying 5v on the 3.3v regulators Vout, and there is a good chance it doesn't deal with that gracefully. Then again you will never use it again, but i do suggest to remove it just in case.
@Deva_Rishi
That is clear; same upload speeds in boards definitions for both 8MHz as for 16Mhz.... hence a crystal twice as fast would expect to see an effective upload speed x2. Which it is not...
I had overlooked that in the actual board definitions, thanks!
Indeed, not healthy for that voltage controller. But I never use that anyway. Removing the voltage regulator? ..should better be done, agreed.
As an experiment you could create a sketch the shows F_CPU (and maybe some other things like baud-rate register settings) on the Serial monitor (at 9600) as well. Upload it with the 8Mhz Crystal still on there, change the Crystal and set the monitor to 19200 and view the result.
F_CPU is a Macro which is defined within the binary.
The Baud-rate registers for an upload are set in the bootloader.
The registers are then set again in the binary.
Interesting. Yet I had been under the assumption all along that the boards.txt for 16MHz would be at 115200 upload speed. It is the case in the McDude MiniCore boards.txt...
So why is it different in the original Arduino Pro Mini boards.txt (ie 57600) for 16MHz?