atmega 2560 burning bootloader

Hello everyone :slight_smile:

I’ve spent more than month in reading and trying to burn bootloader and later to make avr functional. I think I need a help cause I don’t know what is wrong. I’m not so experienced with avr-s, but I have experience in electronic. So let’s start explaining what I’ve done.

I need avr with more I/O than arduino uno that I have. So, I decided to buy atmega 128 (I didn’t forget the zero at the end). It is avr for crumbuino. I made a board for it, and I burned bootloader. For that avr I had to use RX/TX instead of MOSI/MISO/SCK and everything was fine (all uploads), but led blink example didn’t work. :confused: Here is board with avr…

In meantime, I received atmega 2560 and I also made a board for that AVR. Than I didn’t need to change anything in boards.txt. I just chose arduino mega in boards and arduino as asp. I burned bootloader and there was no any errors, than I removed avr chip from arduino and I connected rx and tx from arduino to my board for atmega 2560. I uploaded blink example, but same result like with atmega 128. Pistures of second board…



Board is ok… I tested all connections and everything is fine. I used smd capacitors and cause of that they are may be not visible on pictures. If I didn’t make a board right, than I will not be able to upload a bootloader and sketch.

If someone have some piece of advice I will be thankful.
Regards.

NoX2SR: I used smd capacitors and cause of that they are may be not visible on pictures.

I only see one cap. You need several decoupling caps placed close to each VCC pin. I don't see any supporting caps for the crystall. I also don't see any LEDs so you can actually see it blinking. Yes, I opened the pics, and even if they were smd, they still could be seen unless they are 0201 and/or buried under solder.. I'm shocked that you were able to burn the bootloader and a sketch.

There is 4 capacitors on board. One is between AREF and GND (100nF). That is yellow one on the top of board. I saw that on arduino mega schematic. Than, I have 3 SMD capacitors in down left corner. One 22pF between reset and GND, and two for crystal. You can see a small wire and at the end on wire is capacitor soldered on ground. Diode for blinking is on cable, and I attached it on board after flashing.

OK, I know that board doesn't looks nice, my questions are may be stupid cause, as I said, it is my first time to play with bootloaders. I spent a lot of time on reading some topics on this forum and whole internet and I still have a problem. Is there anyone who wants to help? :)

Pretty cool boards! :) If you were able to upload the sketch via serial line then everything should be good. It means that the bootloader is working properly. LED should blink 3x fast at each startup/reset. It indicate boot from the bootloader. Does it? Blink sketch is very simple and if it works you can measure port level switching with the DMM. Did you select correct port for the LED? 22pF between RST and GND is incorrect but should not be a problem.

I don't have any blinking at startup and also after uploading a ketch. I tried to connect led on several pins but without result. If this can help, here is a sketch and code from console:

int pin = 73;

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(pin, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(pin, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(pin, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}
Board breadboard:avr:atmega328bb doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328BB
Board breadboard:avr:crumbuino128 doesn't define a 'build.board' preference. Auto-set to: AVR_CRUMBUINO128
Board breadboard:avr:atmega128B doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA128B

Sketch uses 1,560 bytes (0%) of program storage space. Maximum is 253,952 bytes.
Global variables use 11 bytes (0%) of dynamic memory, leaving 8,181 bytes for local variables. Maximum is 8,192 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega2560 -cwiring -PCOM8 -b115200 -D -Uflash:w:C:\Users\nemus\AppData\Local\Temp\buildd3ad1c1bd09e1fb54a42a02f5bfd8c0d.tmp/Blink.ino.hex:i 

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM8
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Wiring
         Description     : Wiring
         Programmer Model: AVRISP
         Hardware Version: 15
         Firmware Version Master : 2.10
         Vtarget         : 0.0 V
         SCK period      : 43.5 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9801
avrdude: reading input file "C:\Users\nemus\AppData\Local\Temp\buildd3ad1c1bd09e1fb54a42a02f5bfd8c0d.tmp/Blink.ino.hex"
avrdude: writing flash (1560 bytes):

Writing | ################################################## | 100% 0.29s

avrdude: 1560 bytes of flash written
avrdude: verifying flash memory against C:\Users\nemus\AppData\Local\Temp\buildd3ad1c1bd09e1fb54a42a02f5bfd8c0d.tmp/Blink.ino.hex:
avrdude: load data flash data from input file C:\Users\nemus\AppData\Local\Temp\buildd3ad1c1bd09e1fb54a42a02f5bfd8c0d.tmp/Blink.ino.hex:
avrdude: input file C:\Users\nemus\AppData\Local\Temp\buildd3ad1c1bd09e1fb54a42a02f5bfd8c0d.tmp/Blink.ino.hex contains 1560 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.23s

avrdude: verifying ...
avrdude: 1560 bytes of flash verified

avrdude done.  Thank you.

everything seems to be ok. if not sure of the right pin one thing to try is a simple program to bring all pins on all ports high. then check all with led or meter. it would tell you if a program is being loaded.

It’s alive :smiley:

I did this:

int pin = 74;

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(pin, OUTPUT);
  for(int i=0; i<101;i++)
  {
    pinMode(i,OUTPUT);
  }
}

// the loop function runs over and over again forever
void loop() {
  /*digitalWrite(pin, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(pin, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second*/
  for(int i=0; i<101;i++)
  {
    digitalWrite(i, HIGH);
  }
}

Than, that number of pin that I wrote is incorrect? But I tested it and I really connected the led on the that pin.

I’m finally moved from that dead spot, and I have a wish to continue with experiments. Thanks a lot. :slight_smile:
I wrote a code to blink for a second to every pin and it works, but it doesn’t work if I specify the pin. I tried to make one pin HIGH, and than I measured outputs and I any of them is not HIGH :confused:

edit:

I uploaded this code:

 for(int i = 0; i < 101; i++)
  {
    for(int c = 0; c < i; c++)
    {
      digitalWrite(i, HIGH);
     delay(200);
     digitalWrite(i, LOW);
    delay(200);
    }
  }

And I counted blinks. At pin 74 I have 26 blinks and when I made pin 26 high, I got voltage on pin 74.
It doesn’t have a sense :confused:

arduino company likes to play pranks even if its not april first. you fell for one of them.

atmega2560 ic pin 74 is “arduino” pin 26. when arduino was invented they decided to randomly mix pin numbers up. some say it was to make things easy for beginners but the truth is very confusing for EVERYBODY unless using official arduino products. like the odd pin spacing on shields it was a marketing move.

others like m1284 much worse where everybody and his brother decided to invent their own numbering scheme.

google arduino mega2560 pinout to get arduino to reality conversion table. or heres a diagram i created to make life better for diy builders:

;             pin ard                              pin ard
;              1  d4  OC0B PG5          ,-----------100    AVCC
;  ,-----------2  d0  RXD0/I8 PE0       |,----------99     GND
;  |,----------3  d1  TXD0 PE1          ||          98     AREF
;  |'-tx       4      XCK0/AIN0 PE2     ||          97 a0  PF0 ADC0
;  '--rx       5  d5  OC3A/AIN1 PE3     ||          96 a1  PF1 ADC1
;     r-,      6  d2  OC3B/INT4 PE4     ||          95 a2  PF2 ADC2
;     i-|--,   7  d3  OC3C/INT5 PE5     ||          94 a3  PF3 ADC3
;     o-|-,|   8      T3/INT6 PE6       ||          93 a4  PF4 ADC4/TCK
;     s-|-||-, 9      CLKO/ICP3/INT7 PE7||          92 a5  PF5 ADC5/TMS
;     v-|-||-|-10-----VCC---------------'|          91 a6  PF6 ADC6/TDO
;     g-|-||-|-11-----GND2---------------|          90 a7  PF7 ADC7/TDI
;       | || | 12 d17 RXD2 PH0           |          89 a8  PK0 ADC8/I16
;       | || | 13 d16 TXD2 PH1          .1uf        88 a9  PK1 ADC9/I17
;       | || | 14     XCK2 PH2           |          87 a10 PK2 ADC10/I18
;       | || | 15 d6  OC4A PH3           |          86 a11 PK3 ADC11/I19
;       | || | 16 d7  OC4B PH4           |          85 a12 PK4 ADC12/I20
;       | || | 17 d8  OC4C PH5           |          84 a13 PK5 ADC13/I21
;       | || | 18 d9  OC2B PH6           |          83 a14 PK6 ADC14/I22
;       | || | 19 d53 SS/I0 PB0   led    |          82 a15 PK7 ADC15/I23
;       | || '-20 d52 SCK/I1 PB1---|<-1k-'------,   81     GND
;       | |'---21 d51 MOSI/I2 PB2               '---80     VCC
;       | '----22 d50 MISO/I3 PB3                   79     PJ7
;       |      23 d10 OC2A/I4 PB4                   78 d22 PA0 AD0
;       |      24 d11 OC1A/I5 PB5                   77 d23 PA1 AD1
;       |      25 d12 OC1B/I6 PB6                   76 d24 PA2 AD2
;       |                                          
;       |      26 d13 OC0A/OC1C/I7 PB7 led(ard)     75 d25 PA3 AD3
;       |      27     T4 PH7                        74 d26 PA4 AD4
;       |      28     TOSC2 PG3                     73 d27 PA5 AD5
;       |      29     TOSC1 PG4                     72 d28 PA6 AD6
;       '------30     RESET                         71 d29 PA7 AD7
;              31     VCC                           70 d39 PG2 ALE
;              32     GND                           69     PJ6 I15
;         16---33     XTAL2                         68     PJ5 I14
;         mhz--34     XTAL1                         67     PJ4 I13
;              35 d49 ICP4 PL0                      66     PJ3 I12
;              36 d48 ICP5 PL1                      65     PJ2 XCK3/I11
;              37 d47 T5 PL2                        64 d14 PJ1 TXD3/I10
;              38 d46 OC5A PL3                      63 d15 PJ0 RXD3/I9
;              39 d45 OC5B PL4                      62     GND
;              40 d44 OC5C PL5                      61     VCC
;              41 d43 PL6                           60 d30 PC7 A15
;              42 d42 PL7                           59 d31 PC6 A14
;              43 d21 SCL/INT0 PD0                  58 d32 PC5 A13
;              44 d20 SDA/INT1 PD1                  57 d33 PC4 A12
;              45 d19 RXD1/INT2 PD2                 56 d34 PC3 A11
;              46 d18 TXD1/INT3 PD3                 55 d35 PC2 A10
;              47 d17 ICP1 PD4                      54 d36 PC1 A9
;              48 d16 XCK1 PD5                      53 d37 PC0 A8
;              49 d15 T1 PD6                        52 d40 PG1 RD
;              50 d14 T0 PD7                        51 d41 PG0 WR

note that arduino decided to put led on ic pin 26 (sometimes called arduino pin 13). another silly decision to make things difficult. like grounding the led instead of vcc like everybody else. for my own boards i use vcc and put it on ic pin 20 (sck) which makes much more sense for a variety of reasons.

John, pin numbering is not totally randomly defined, I think. Yes, you are right, sometimes it is confusing, but consider the fact that each MCU type, and there are not only ATmegas, it has different pinout and pin functionality combination. It differs even with IC package type. In addition, no all of MCU's pins can be used as I/O. That is the reason why the pins_arduino.h exists. As an example, the I2C on the R3 version - SDA, SCL were added next to AREF and it was simply because I2c was previously on different place for each board type - really bad for I2C shields.

Finally, the ATmega1284. I have also my own version of pinout which I will prefer till the end of time, probably. :) Don't forget that official Arduino 1284 board doesn't exists and naturally, how many people so many flavors. I passed through the board design process. It takes a lot of time and one can never be sure that it is perfect.

Big thanks to you guys :) I finally can continue with my project. :)

Here is picture that I found. It will may be help to someone. |486x500

To avoid confusion I wrote this and now I will fallow a real pins...

 /*Analog pins*/
 int aPin97 = A0;
 int aPin96 = A1;
 int aPin95 = A2;
 int aPin94 = A3;
 int aPin93 = A4;
 int aPin92 = A5;
 int aPin91 = A6;
 int aPin90 = A7;
 int aPin89 = A8;
 int aPin88 = A9;
 int aPin87 = A10;
 int aPin86 = A11;
etc...