As noted in 6v6gt's answer, if the ATmega328 has been set to use a crystal, thereafter a crystal (or an external oscillator) are required for programming, until the fuses have been set to use the internal RC oscillator. Here are a few thoughts, unfortunately somewhat scattered, on the matter.
If you have a parallel programmer (that delivers high voltage to the Reset pin and uses 8-bit parallel data signalling) you can use it to reset the fuses, since with that programming mode the clock is irrelevant.
Also, I think some versions of USBaspUSBasp programmers interact with Avrdude to generate a programming clock of some specified frequency, 100kHz by default, 8kHz with the "Slow Clock" jumper installed. Also see § "Set the clock in software" within USBasp ICSP programmer quickstart guide at freetronics.com.au. Unlike the Avrdude man page, that reference says the default programming frequency is 375kHz and may be ablesays "Avrdude’s -B option allows you to set the programming clock speed from software", while the man page says -B specifies bit clock period (in microseconds) for the JTAG interface or the ISP clock of the JTAG ICE only. Anyhow, a USBasp can reprogram fuses away from the crystal setting. However if a crystal or external oscillator is used, some USBasp clones ignore AVRdude's commandswithout depending on serial port data rates. I don't know for frequency settingcertain whether it will work without a crystal or oscillator.
RatherNote, rather than "sharing" a crystal via wires from one board to another – a practice that will broadcast lots of RF noise and might not get the signal across anyway – you could instead write a program on one Arduino to toggle a pin at high frequency, and use that output as an external oscillator to drive one of the crystal pins on another chip. For example, the program below should generate a 2.67 MHz square wave on pin PB0 of an Uno or a Nano.
void setup() {
cli(); // Avoid timer interrupts
pinMode (8, OUTPUT); // PB0 is pin 8 on Uno / Nano
while (1) PINB = 1;
}
void loop() {}
In the ATmega328 data sheet, see §14.3.1, Alternate Functions of Port B, and Table 14-3, which lists PB7 as XTAL2 (Chip Clock Oscillator pin 2), and PB6 as XTAL1 (Chip Clock Oscillator pin 1 or External clock input), indicating external oscillator attaches to the PB6 pin.
As noted in 6v6gt's answer, if the ATmega328 has been set to use a crystal, thereafter a crystal (or an external oscillator) are required for programming, until the fuses have been set to use the internal RC oscillator. Here are a few thoughts, unfortunately somewhat scattered, on the matter.
If you have a parallel programmer (that delivers high voltage to the Reset pin and uses 8-bit parallel data signalling) you can use it to reset the fuses, since with that programming mode the clock is irrelevant.
Also, I think some versions of USBasp generate a programming clock and may be able to reprogram fuses away from the crystal setting. However, some USBasp clones ignore AVRdude's commands for frequency setting.
Rather than "sharing" a crystal via wires from one board to another – a practice that will broadcast lots of RF noise and might not get the signal across anyway – you could instead write a program on one Arduino to toggle a pin at high frequency, and use that output as an external oscillator to drive one of the crystal pins on another chip. For example, the program below should generate a 2.67 MHz square wave on pin PB0 of an Uno or a Nano.
void setup() {
pinMode (8, OUTPUT); // PB0 is pin 8 on Uno / Nano
while (1) PINB = 1;
}
void loop() {}
As noted in 6v6gt's answer, if the ATmega328 has been set to use a crystal, thereafter a crystal (or an external oscillator) are required for programming, until the fuses have been set to use the internal RC oscillator. Here are a few thoughts, unfortunately somewhat scattered, on the matter.
If you have a parallel programmer (that delivers high voltage to the Reset pin and uses 8-bit parallel data signalling) you can use it to reset the fuses, since with that programming mode the clock is irrelevant.
Also, USBasp programmers interact with Avrdude to generate a programming clock of some specified frequency, 100kHz by default, 8kHz with the "Slow Clock" jumper installed. Also see § "Set the clock in software" within USBasp ICSP programmer quickstart guide at freetronics.com.au. Unlike the Avrdude man page, that reference says the default programming frequency is 375kHz and says "Avrdude’s -B option allows you to set the programming clock speed from software", while the man page says -B specifies bit clock period (in microseconds) for the JTAG interface or the ISP clock of the JTAG ICE only. Anyhow, a USBasp can reprogram fuses away from the crystal setting if a crystal or external oscillator is used, without depending on serial port data rates. I don't know for certain whether it will work without a crystal or oscillator.
Note, rather than "sharing" a crystal via wires from one board to another – a practice that will broadcast lots of RF noise and might not get the signal across anyway – you could instead write a program on one Arduino to toggle a pin at high frequency, and use that output as an external oscillator to drive one of the crystal pins on another chip. For example, the program below should generate a 2.67 MHz square wave on pin PB0 of an Uno or a Nano.
void setup() {
cli(); // Avoid timer interrupts
pinMode (8, OUTPUT); // PB0 is pin 8 on Uno / Nano
while (1) PINB = 1;
}
void loop() {}
In the ATmega328 data sheet, see §14.3.1, Alternate Functions of Port B, and Table 14-3, which lists PB7 as XTAL2 (Chip Clock Oscillator pin 2), and PB6 as XTAL1 (Chip Clock Oscillator pin 1 or External clock input), indicating external oscillator attaches to the PB6 pin.
As noted in 6v6gt's answer, if the ATmega328 has been set to use a crystal, thereafter a crystal (or an external oscillator) are required for programming, until the fuses have been set to use the internal RC oscillator. Here are a few thoughts, unfortunately somewhat scattered, on the matter.
If you have a parallel programmer (that delivers high voltage to the Reset pin and uses 8-bit parallel data signalling) you can use it to reset the fuses, since with that programming mode the clock is irrelevant.
Also, I think some versions of USBasp generate a programming clock and may be able to reprogram fuses away from the crystal setting. However, some USBasp clones ignore AVRdude's commands for frequency setting.
Rather than "sharing" a crystal via wires from one board to another – a practice that will broadcast lots of RF noise and might not get the signal across anyway – you could instead write a program on one Arduino to toggle a pin at high frequency, and use that output as an external oscillator to drive one of the crystal pins on another chip. For example, the program below should generate a 2.67 MHz square wave on pin PB0 of an Uno or a Nano.
void setup() {
pinMode (8, OUTPUT); // PB0 is pin 8 on Uno / Nano
while (1) PINB = 1;
}
void loop() {}