Second ATMega chip?

I have a project I'm getting ready to start that will need an ATMega328 chip on its own individual project board. The question I then have is how best to upload a sketch to it prior to putting it on that project board.

As I see it (and I'm just a beginner with this), I have three "potential" options:

  1. I load the sketch into the ATMega chip on the Arduino Uno board and then use a soldering iron to remove that chip from the Arduino Uno board so that I can put it onto the project board (then requiring me to install a replacement chip onto the Arduino Uno board).

  2. Remove the existing chip from the Arduino Uno board and then install the replacement chip. Load the sketch into the replacement chip. Remove the replacement chip from the Uno board and put the original chip back in place. Install the replacement chip onto the project board.

  3. Now this is the option that my question concerns (whether or not this is possible). Is it possible to connect a second ATMega chip (in parallel) to the existing ATMega chip, on the Arduino Uno board, so that when I program one I'm also programming the other at the same time? I could connect them with jumper wires. That way I'd never have to remove the existing chip from the uno board.

Or, does anyone know of any other way I can get my individual ATMega328 chip loaded with a sketch without having to significantly alter the Uno board?

Doesn't your board have a '328P in a socket? Or you have a surface mount board? (available for a time when DIP parts were in short supply). You can use the Arduino as a programmer to program the second chip: Check Program Bootloader here, and Programming a Sketch farther down the same page http://www.gammon.com.au/forum/index.php?bbtopic_id=123

If you are talking about the project board, it is just a plain piece of breadboard with nothing whatsoever on it. Basically what I want to do is to program two ATMega chips, simultaneously, from a single Arduino Uno board. If that is not possible, then I'll have to load the sketch into the existing chip on the Uno board and then remove the chip from that board and put the chip onto my board.

And as I said, this is my first time. I'm a beginner. So most of what you put into your reply I did not understand. Pretend you are talking to a 10 year old.

No, there is no socket on my Uno board. The chip is soldered into place directly to the holes in the circuit board.

Then your chip is a Surface mount. Reread CrossRoads' reply and look up ICSP. DO NOT attempt to remove the chip. How would you use it in a breadboard setup anyway?

You need to do 2 things: 1. Install a bootloader into the blank chip 2. Down the sketch into the blank chip

Step 1. Install the bootloader. a. Install the bootload installation sketch into the board per Nick' procedures. b. Make these connections to the blank chip: chip board 1 D10 7 +5 8 Gnd 17 D11 (MOSI) 18 D12 (MISO) 19 D13 (SCK) 20 +5 22 Gnd

Chip will also need 16 MHz crystal between pins 9 & 10. Chip will also need 22pF cap from pin 9 to Gnd Chip will also need 22pF cap from pin 10 to Gnd Chip will perform better (more reliably) with 0.1uF cap from pin 7 to Gnd Chip will perform better (more reliably) with 0.1uF cap from pin 20 to Gnd

This setup makes the chip look like an unprogrammed board, with a programming cable connected. The programming cable controls the chip's Reset pin to put the chip into bootloader programming mode.

c. Run the sketch per Nick's webpage. This sets up the chip as an Uno. http://www.gammon.com.au/forum/?id=11635

Step 2. Install the sketch. Remove the connections to pin 1, 17, 18, 19 Add these connections: chip board 1: add a 10K pullup resistor from chip pin 1 to +5. wire a switch from pin 1 that connects to Gnd when pressed.

Connect Reset on the board to Gnd - this disables the onboard processor

2 D0 (Rx) 3 D1 (Tx) 7 +5 (left from bootloading) 8 Gnd (left from bootloading) 20 +5 (left from bootloading) 22 Gnd (left from bootloading)

This lets you use the board's USB/Serial adapter to download a sketch.

In the IDE, select File:Preferences, turn on verbose outputs. Select Tools:Board type as Uno. Select the correct Tools:Serial port

Press & hold the chip's reset button. When you see "Compiled xxx of 32xxx bytes" release the reset button. May take a couple of tries to get the timing right.

Hopefully I didn't leave anything out.

It don’t get much more complete than that, or simplier.
Still like to know how he’s going to plug that SMT into the breadboard…

See attached pictures.

Below is sketch:

(Code tags added by moderator - please use them in the future - see # button)

#define CONSERVATIVE

int ioPin = 3;
#define BUFSIZE 200
unsigned char buf[BUFSIZE];

#define pullLow() pinMode(ioPin, OUTPUT)
#define pullHigh() pinMode(ioPin, INPUT)

unsigned char dbits[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0};

unsigned char bits[][144] = {
  {
    0, 0, 0,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ioPin, OUTPUT);
  digitalWrite(ioPin, LOW);
  pinMode(ioPin, INPUT);
  digitalWrite(ioPin, LOW);

  for(int i = 0; i < sizeof(dbits); ++i) {
    if(dbits[i] == 0) {
      pullLow();
      delayMicroseconds(16);
      pullHigh();
      delayMicroseconds(190);
    } else {
      pullLow();
      delayMicroseconds(16);
      pullHigh();
      delayMicroseconds(56);
      pullLow();
      delayMicroseconds(16);
      pullHigh();
      delayMicroseconds(112);
    }
  }

  pullLow();
  delayMicroseconds(16);
  pullHigh();

  bval = 0;
  attachInterrupt(1, wentLow, FALLING);

  unsigned int i = 0;
  while(digitalRead(ioPin) == HIGH && i++ < 32767) {}
  if(i == 32767)
    return false;

  delayMicroseconds(20);
  for(int i = 0; i < 164; ++i) {
    buf[i] = 0;
    pullLow();
    delayMicroseconds(8);
    pullHigh();
    bval = 0;
    delayMicroseconds(184);
    buf[i] = bval;
  }

  for(int i = 0; i < 32+3; ++i)
    bits[0][50+i] = buf[22+i];

  for(int i = 0; i < 8; ++i)
    bits[0][86+i] = bits[0][50+i] ^ bits[0][50+9+i] ^ bits[0][50+18+i] ^ bits[0][50+27+i];
  bits[0][86] ^= 1;
  bits[0][87] ^= 0;
  bits[0][88] ^= 1;
  bits[0][89] ^= 1;
  bits[0][90] ^= 1;
  bits[0][91] ^= 0;
  bits[0][92] ^= 1;
  bits[0][93] ^= 1;

#ifdef CONSERVATIVE
  delay(100);
#endif
  for(int j = 0; j < 11; ++j) {
    for(int i = 0; i < sizeof(bits[j]); ++i) {
      if(bits[j][i] == 0) {
        pullLow();
        delayMicroseconds(16);
        pullHigh();
        delayMicroseconds(190);
      } else {
        pullLow();
        delayMicroseconds(16);
        pullHigh();
        delayMicroseconds(56);
        pullLow();
        delayMicroseconds(16);
        pullHigh();
        delayMicroseconds(112);
      }
    }
#ifdef CONSERVATIVE
    delayMicroseconds(2700);
#else
    delayMicroseconds(500);
#endif
  }
  return true;
}

void loop() {
    open();
}

arduino project picture.bmp (327 KB)

Arduino project board closeups

I'm out'a here.

Man are they gonna jump on you. look up code tags.

The code question should be a seperate topic from the loading question. (Is there a question?)

16 MHz and 3.3V don’t really go together, altho it may work. See chart of clock speed vs supply voltage.
Gonna have to remove the tape to get at the pins for bootloading and downloading.
Need AVCC connected to VCC.
Need 0.1uF caps on VCC, AVCC.
Should have 22pF caps on the crystal pins.