Standalone Atmega328 programming problem

Hi! I use AVR Pocket Programmator, Atmega 328P 32 pin version (ATMEGA328P-AU MICROCHIP (ATMEL) - IC: mikrokontrolér AVR | EEPROM: 1kB; SRAM: 2kB; Flash: 32kB; TQFP32 | TME Czech Republic s.r.o. - Elektronické součástky), Arduino IDE and AVRDude for my single Atmega328P (with internal oscillator) programming via ISP. When programming in Arduino IDE, I choose Atmega 328, Internal 8 Mhz oscillator from boards (added to boards.txt) and use Upload Using Programmer procedure. The sketch is uploaded successfully, but the code doesn't work. I tried to upload exported HEX directly in AVRDude too. But the result was the same. The test code defines pin 26, set the pin as output and blinks the LED. Where could be a problem? Is there any problem in pins mapping? I have alternativelly tested programming in Atmel Studio in C and then uploaded hex with a help of AVRDude, the LEDs are blinking without any problem in such case.

The problem was sold solved faster then I thought :slight_smile: The problem was really in pin mapping, because one of the pins is analogue in Arduino.

BUT, I see an another problem. Even if the delay is delay(1000); every cycle (off and on) takes several seconds. Why does it go so slow?

vracmi:
Why does it go so slow?

Probably because the actual clock speed doesn't match the F_CPU value the code was compiled with. The ATmega328P comes from the factory with the fuses set to run at 1 MHz from the internal oscillator. The way to change fuses in the Arduino IDE is to do Tools > Burn Bootloader, which sets fuses according to the boards.txt definition of the currently selected board before flashing the bootloader to the microcontroller. If you don't have an external clock source attached to the ATmega328P then you need to be careful not to set fuses for an external clock as this will "brick" your microcontroller until you can provide a clock source.