I am programming an ATmega328p chip on a breadboard using a arduino with some firmware that then runs on a pcb. As I dont have a spare crystal I am uploading the code using the internal crystal of the ATmega. Code seems to upload ok but then the chip doesn't seem to be working the way it should when used in the PCB.
Would uploading the code using the internal crystal change the way the code is ran when I add it to the pcb?
So you are using the 1MHz internal osc. and you are asking if it is different from using an external 16MHz crystal. The answer is YES. It will run at 1/16th of the speed.
I'm using the internal crystal to get the code loaded onto the chip but then using the chip in a circuit with a 16mhz crystal. Will the chip still run at the slower speed?
Thanks for this. So basically I will need to transfer code to chip using 16mhz crystal if I then want to use it in a circuit board that also has a 16mhz crystal
There is no "internal crystal". There are several RC oscillators.
So basically I will need to transfer code to chip using 16mhz crystal
No, you can use any clock source for programming. For proper program operation with timing dependent functions like serial input and output, millis(), etc. you need to tell the IDE what the oscillator frequency is.
Do you have any junk circuit boards around? maybe one of them has a crystal. Look for something between 4 and 20 MHz.
Adafruit has a version of the ArduinoISP sketch that generates an 8MHz clock on Pin 9:
Just connect Pin 9 of the ISP Arduino to the XTAL1 pin (physical pin 9, counterclockwise from the pin 1 mark) and upload the bootloader or sketch as if it was a 16 MHz UNO or Nano. The 8 MHz clock replaces the crystal and lets you upload into a chip set to expect a crystal.