mega2560 standalone problem

Hello

I’ve done a project on arduino mega 2560 and want to move it to a pcb that i’ve designed and had manufactured. I’ve soldered everything together and uploaded the blink sketch using usbasp (i have a led on digital pin 4). It run very slowly. After searching with google, i’ve learned that i need to set the fuse bites to use the externel crystal (it’s a brand new atmega 2560). So i’ve burned the bootloader (it’s supposed to set those bytes). Now the blink sketch will upload but won’t do anything, but when i upload:

#ifndef F_CPU
#define F_CPU 16000000UL
#endif

#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
DDRG = (1<<PG5);

while(1)
{
//LED On
PORTG = (1<<PG5);
_delay_ms(1000);

//LED Off
PORTG = (0<<PG5);
_delay_ms(1000);
}
}

it runs ok. Can anyone help me? How to solve this problem?

Is the blink sketch assuming the correct pin for the LED? On the official board, it's on PB7, and blink uses that. In the code you showed above, it's on PG5.

The led is connected to PG5 witch is digital pin 4 on arduino. Before burning the bootloader/ setting the fuse bits the blink sketch (set to digital pin 4) worked, but slowly. From what i found through google it was running on the internal oscilator set to 1 MHz.

I’ve just solved the problem.

I set the fuses with avrdude, chose settings with a fuse bits calculator:
http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega2560

In my case (16 MHz crystal) the complete command was:

avrdude -c usbasp -p m2560 -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xFF:m -U lock:w:0xFF:m