ATMEGA644A-AU strange clock speed

I have made on a breadboard a project using ATMEGA644-20PU (16MHz crystal and 22pF capacitors) and I programmed the microcontroller using Arduino uno as ISP (I used Arduino 1.6.5 and I installed the Sanguino platform at the following URL https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json). Everything worked fine.

Now I have made a PCB using ATMEGA644A-AU (16MHz smd crystal with 22pF capacitors). I am able to program successfully the microcontroller with the same software configuration described before. However, I notice that the CPU speed is much less than 16MHz (when I run a sketch testing the serial communication I notice that the true baud rate is 600baud/s instead of 9600 baud/s). Moreover, when I run a blink sketch I notice that the blink time is different form what I expect.

I have also replaced the smd crystal with the through-hole crystal I used in breadboard but nothing has changed.

How to fix the problem? Should I sobstitute the ATMEGA644A with ATMEGA644P?

Thanks in advance

You need to set the fuses by selecting the appropriate board, connecting ISP programmer, and doing 'burn bootloader' (even if you're not using a bootloader - the bootloader (if any) will be overwritten if you then program via ISP, but the fuses will not be) - this will set the fuses, which, among other things, tell it what to use for the system clock.

Since you haven't done that, it's using the default option - 8mhz internal clock divided by 8 to get a 1mhz system clock. Hence all the time keeping is going at 1/16th the expected speed :wink:

You can also do this using avrdude from the command line, or a tool like eXtremeBurner AVR (windows tool for USB Asp programmer)