I have a PCB board, which has an atmega328p with an external 8MHz crystal on it. I was wondering how could I program the chip using the Arduino IDE if the PCB also has an ICSP header on it. I found this tutorial, which explains how to install a bootloader and program the chip, which uses an 16MHz external clock.Since I have an ICSP interface on the PCB, should I have to load the bootloader on the chip? There's probably some configuration which has to be done (to tell the IDE that the chip is using an external 8MHz crystal as opposed to running on an internnal RC-oscillator at 1MHz, by default)?
Does somebody know, what should be done? I have a programmer (avrispmk2) which will be used to program the chip over ICSP.
The bootloader is a program that gets loaded by ICSP.
I think you should be able to use the same technique to load any program.
You will need to choose the correct board type before compiling the program. I have several Atmega 328s using the internal 8MHz clock but I have never use an external crystal. And I have loaded the bootloader on my 328s. I do use ICSP for programming Attiny1634s. I have a breadboard Atmega 328 that I use as my programmer.
Nick Gammon's chip detect progam may be useful. He also has a few other utility programs.
...R
You can easily add an 8MHz menu option in the Arduino IDE. Here's how to do it: https://tttapa.github.io/Arduino/ATmega328P/Custom-frequency.html
Pieter
Breadboard duino with better software and tutorial provided.
The official Arduino breadboard duino example is painful compared.
I got bare AVR's from Mouser for less than ever. 1284P-PU for $5.51, 40 pins and 16K ram, covered in the tutorial above.
Question is do you need the crystal for precise timing? Because the chip has an internal 8MHz oscillator, if you use it then you free 2 pins (on 328P PORTB, all 8 bits become open to use).
If the chip needs an external source to bet a new bootloader burned then see if the board it's on now has an ICSP header or access to those pins, you can jumper a header to the board same as a breadboard.
The tutorial covers all permutations and leaves you knowing why you choose as you do, it's good. Give Nick Karma!
There is a good ATtiny tutorial on the MIT High Low Tech site.
Thank you all! Will try it out.