0
votes

I have successfully programmed standalone ATmega328p using an Arduino uno by adding following lines in the boards.txt file:

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)
atmega328bb.upload.protocol=stk500
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600
atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
####atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F
atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=standard
atmega328bb.bootloader.tool=arduino:avrdude

The bootloader worked and I was able to run blink example successfully on a standalone ATmega328p.

Now, I am trying to upload a blink example to the standalone ATmega2560. I selected the board as ATmega2560 from the Tools menu (in-built board ATmega2560) and ran the bootloader. I didn't make any changes for the ATmega2560 in the boards.txt file) The bootloader worked and the code was uploaded to the ATmega2560 successfully.

However, the problem is that the blink example is not working. The LED on pin 26 on a standalone board turns ON for a very short period then turns OFF for a very short period and then again turns ON for a short period and finally turns OFF for 1 second. This cycle is repeated. However, the blink code should turn the LED ON then provides a delay of 1 second and then turns off for a 1 second and this cycle is repeated. The blink code is not working as it should work on my standalone ATmega2560

I tested the same thing using a TIMER1. I wrote code to blink the LED after every 0.03 seconds. This works fine in standalone ATmega328p but it doesn't work on a Standalone ATmega2560.

What would be the problem? Do I need to add some lines for standalone ATmega2560 in the boards.txt file?

I connected all VCC pins, GND pins and crystal including the filter capacitor and resistor as shown in the fig.

After, I connected the reset pin to 5v through a 10k resistor.

After, I did the following:

  • Arduino Uno pin 10 to reset pin of standalone ATmega2560
  • Arduino Uno pin MISO to pin MISO of standalone ATmega2560
  • Arduino Uno pin MOSI to pin MOSI of standalone ATmega2560
  • Arduino Uno pin SCK to pin SCK of standalone ATmega2560

Please help!

1
Grammar fixes and typosrayryeng
This is probably more suited for Electrical Engineering StackExchange: electronics.stackexchange.comrayryeng

1 Answers

0
votes

In the Board.txt file, in the ATMEGA2560 section, you have to replace the value of "0xD8" with "0xD9". This is so, because in stand-alone ATMEGA2560 chips, if the BOOTRST fuse is not set, the chip will be correctly programmed, but the programs will never run. So the line could look like this ( we can keep the original line commented ):

#mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD8

mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD9

A tutorial here : https://soc.ninja/documentation/programming-atmega2560-with-arduino-uno-or-mega/