I have a project where i need to use a specific external clock source (not a crystal or resonator) that is running at 8MHz.
For now, I'm proposing to use a Uno board with a DIP package Atmega328P as it helps me with a lot of the serial interfacing i'll need to do while debugging my upcoming code development. I will be raising the chip up using a second 28pin DIP socket and bending physical pin #9 of the socket outwards to allow it to receive the 8MHz external clock signal.
I've been looking around for some guidance on how to re-burn the bootloader of the uno directly to set the fuses at allow the external clock source, but there seems to be little info available on this. The best I see are projects to remove the Atmega328P from the Uno, burn the fuses off a breadboard and then reinsert the chip on the uno board.
Does anyone have any guidance on this? Perhaps I'm just making life hard for myself and should just go with the breadboard option.
Tools > Programmer > select your ISP programmer (if you don't have one, you can turn a spare Arduino board into an "Arduino as ISP")
Connect your programmer to your Uno's ICSP header.
Connect your programmer to your computer.
Tools > Burn Bootloader
Make sure to continue using the same MiniCore board and Clock menu selections after this. You can't go back to using the Tools > Board > Arduino AVR Boards > Arduino Uno board selection because that is configured for 16 MHz.
I will try this soon. I do have the option of using 16MHz from the external clock source, but the waveform isn't as clean. While I was sitting here just pondering and without changing any bootloader or fuses, I simply connected the 16MHz external clock to physical pin #9 that i've bent up. That works. However, my two issues with this are with the stability of the clock waveform and now Pin 10 is a bit of a redundant pin - but really working on the UNO it always will be unless I rewire it too.
I'll see how stable the 16Mhz remains. If i'm not happy with how that goes, I'll revert to the 8Mhz and follow your helpful guidance. I have an ISP programmer, so can use that.
One thing I took from your guidance is that the bootloader is 100% to do with the chip itself and has absolutely nothing to do with the surrounding circuitry of the Uno (except for the bit to do with burning the bootloader and perhaps the clock source). Would that be a resonable statement?
One somewhat unintuitive thing about the Arduino IDE's "Burn Bootloader" feature is that it actually does two things:
Sets fuses according to the board definition.
Flashes the bootloader to the microcontroller.
In fact, if you don't need a bootloader, you can select "No bootloader" from the custom Tools > Bootloader menu MiniCore adds to the Arduino IDE and this will cause "Burn Bootloader" to only set the fuses, leaving you with the full flash memory of the microcontroller to use for your sketch. Without the bootloader, you will need to use the ISP to upload, which the Arduino IDE also supports (done with Sketch > Upload using Programmer, but the "No bootloader" setting also makes the normal upload do the same thing for convenience).
The bootloader receives the binary data of the program over serial, which is timing sensitive, so the bootloader is compiled for a specific clock speed. So in this way the bootloader is dependent on the clock.
The bootloader runs when the microcontroller is reset. So at the start of the upload, there must be a reset. For convenience, the Uno has a circuit that automatically generates the low pulse on the reset pin at just the right time. So in that way, the bootloader is also somewhat dependent on the auto-reset circuit, but you could just as well manually reset the microcontroller at the start of the upload.
AFAIK the bootloader of the simple ATmega controllers always works with the internal 8MHz RC clock, independently of any external clock.
Have a look at the Pro Mini configuration files, which mainly differ in the 8 or 16 MHz clock. Eventually you can retype your Uno as a 3.3V 8MHz Pro Mini for software compatibility?
No, the bootloader runs from the same clock source as the sketch. You can see here that the 16 MHz version of the Pro Mini has a different bootloader from the 8 MHz version. The bootloader code is the same for each, it's just that the F_CPU macro is set to 16000000L when compiling one and 8000000L when compiling the other:
You will find some 3rd party boards platforms that use the same bootloader file for both clock speeds. For example:
The explanation:
# For 8MHz using the internal RC Oscillator, we adjust fuses, use the same
# bootloader binary, and halve the upload rate.
So the bootloader is compiled to run at 16 MHz and communicate at 115200 baud, so when that bootloader is used on an 8 MHz board, the upload baud rate on the PC must be set to 57600 baud because the clock on the microcontroller is running at half the speed the bootloader expects.