Burn bootloader without access to a crystal.

I have a breadboard Atmega328P from adafruit.
When I bought it, I did not see that it was configured to use an external oscillator. I do not have one, so what can I do to burn the chip with a new bootloader (one configured to use the internal oscillator)?

I was able to use Nick Gammon’s code to burn the bootloader, which seemed to work, but still I cannot use my TinyAVR to program it (yet I can use it to program my Uno)

I have tried using a sketch that makes an external Uno board generate a 8MHz frequency, and connected that up to pin X1 (and X2, neither work)

Here is the code I used to generate the frequency:

// Use of timer2 to generate a signal for a particular frequency on pin 11

const int freqOutputPin = 11;   // OC2A output pin for ATmega328 boards
//const int freqOutputPin = 10; // OC2A output for Mega boards

// Constants are computed at compile time

// If you change the prescale value, it affects CS22, CS21, and CS20
// For a given prescale value, the eight-bit number that you
// load into OCR2A determines the frequency according to the
// following formulas:
// With no prescaling, an ocr2val of 3 causes the output pin to
// toggle the value every four CPU clock cycles. That is, the
// period is equal to eight slock cycles.
// With F_CPU = 16 MHz, the result is 2 MHz.
// Note that the prescale value is just for printing; changing it here
// does not change the clock division ratio for the timer!  To change
// the timer prescale division, use different bits for CS22:0 below
const int prescale  = 1;
const int ocr2aval  = 3; 
// The following are scaled for convenient printing

// Period in microseconds
const float period    = 5.0 * prescale * (ocr2aval+1) / (F_CPU/1.0e6);

// Frequency in Hz
const float freq      = 1.0e6 / period;

void setup()
    pinMode(freqOutputPin, OUTPUT);

    // Set Timer 2 CTC mode with no prescaling.  OC2A toggles on compare match
    // WGM22:0 = 010: CTC Mode, toggle OC 
    // WGM2 bits 1 and 0 are in TCCR2A,
    // WGM2 bit 2 is in TCCR2B
    // COM2A0 sets OC2A (arduino pin 11 on Uno or Duemilanove) to toggle on compare match
    TCCR2A = ((1 << WGM21) | (1 << COM2A0));

    // Set Timer 2  No prescaling  (i.e. prescale division = 1)
    // CS22:0 = 001: Use CPU clock with no prescaling
    // CS2 bits 2:0 are all in TCCR2B
    TCCR2B = (1 << CS20);

    // Make sure Compare-match register A interrupt for timer2 is disabled
    TIMSK2 = 0;
    // This value determines the output frequency
    OCR2A = ocr2aval;

    Serial.print("Period    = ");
    Serial.println(" microseconds");
    Serial.print("Frequency = ");
    Serial.println(" Hz");

void loop()
    // Do (almost) anything you want here.  Just don't do analogWrite to
    // pins controlled by Timer 2.  In fact, don't do anything that messes
    // with the registers in Timer 2.

This has been an ongoing (and quite frankly, frustrating) issue.
Any help appreciated! :slight_smile:

Did you connect the grounds?

Did you connect the right pin?

Also - 20 pcs, 16mhz crystal, 99 cents shipped (no specific endorsement of this vendor - ebay is full of listings like this), http://www.ebay.com/itm/112173309823 And 100 22pf loading caps, 99 cents shipped http://www.ebay.com/itm/122020998251

Yes, I know. This did not, however, answer my question in any way -_-

It doesn’t really matter what frequency you use for the external oscillator, as long as the programmer operates at less than 1/4 that frequency.

I might be able to help further, but you have not clearly explained what you have done so far.

How, exactly, did you manage to “burn the bootloader”? Which bootloader and with what options?

BTW, the MiniCore bootloader is the most flexible and allows you to choose the internal 8 MHz RC oscillator as the clock source.