Setting up ATMEGA328P

Hello,
I am trying to make a temperature logger without Arduino Duemilanove board. I would like to load the code on board Duemilanove then remove the chip and put it on breadbord with all the connections to sensor, RTC and SD card reader.

I must install "ATmega328 on a breadboard (8 MHz internal clock)."
There are only configuration files for Arduino IDE 1.0, 1.5, 1.6 so for the newest Arduino IDE 1.8 there is none.

If I install Arduino IDE 1.6 and the appropriate internal clock configuration file then can I further program the chip using Arduino IDE 1.8 ? Because all the necessary libraries are installed to 1.8

AFAIK, you cannot do what you want. You must use arduino as ISP and load the code onto the chip while it is on the breadboard. There are several guides on how to do this: link - link - link.

Ok, I thought that I can program the chip on Arduino Duemilanove and then just remove it and use (with program code loaded).

You can load program code (a sketch) in the manner you have described. But that is not enough. You need a programmer, as has already been stated, or another Arduino configured as one to load the 8MHz boot loader and change the fuses to use the internal oscillator.

Your best option is probably to buy a new ATMEGA328P-PU chip and use your Duemilanove as an ISP programmer to burn the 8MHz bootloader onto the new chip. Then reconfigure the Duemilanove (as a USBTTL device) to upload sketches to the new chip.

6v6gt:
You can load program code (a sketch) in the manner you have described.

Will the 16MHz oscillator/crystal on the board not be a problem in regards of the wanted internal 8MHz clock?

I've tried with an 8MHz 328P in an UNO and it did not work, on a breadboard with the chip removed from the UNO it was no problem, though :slight_smile:

Danois90:
Will the 16MHz oscillator/crystal on the board not be a problem in regards of the wanted internal 8MHz clock?

I've tried with an 8MHz 328P in an UNO and it did not work, on a breadboard with the chip removed from the UNO it was no problem, though :slight_smile:

My experience is this, that if the fuses are set to use the internal oscillator, then the ATmega328P chip will ignore any crystal present. This fuse setting is done as a side effect of burning the bootloader for the chosen target board. I guess there may have been other factors which lead to the failure you described.

If, however, there is a mismatch between the clock frequency of the selected target board type in the IDE and the actual clock frequency of the board, then attempts to load a sketch may fail.

The correct order is:

  1. Configure the ATmega328P chip so it matches its current fuse settings for the oscillator. This may mean, for example, (temporarily) adding a 16MHz crystal.

  2. Connect an ISP programmer (or say a Uno configured as one) and select the target board type in the IDE, then select burn boot loader. This also sets the fuses.

  3. Disconnect the ISP programmer and connect a USBTTL device (or say a Uno configured as one) and load a sketch. For this stage, it should even be possible to put the chip into a UNO etc., but the board type selected in the IDE must match that declared in 2 above.

I actually manage to get the ATMEGA328 work so that I loaded my code on Duemilanove board, removed the controller and put it on breadboard, where i added two 22 picofarad capacitors, one 16 MHz crystal and all the components of my project (SD card reader, RTC, LM35 temp sensor). And it is working.

You need 100 nF decoupling caps on the ATmega chip for reliable operation, as described here.

Also, don't forget the reset pin. AVR042 presents most hardware design considerations.