Standalone Mega2560 boot time

No it's not normal. Try the bootloader (for the 2560) from here:

Are they the actual fuse settings? Or what is in board.txt?

Use avrdude to read back the signatures fuses and show us that.

The fuses settings are from boards.txt and they are the actual fuses settings.

I tried the firmware, no change.

I'm not using avrdude, but AtmelStudio 6. Can this be an issue ?

Can you read the fuses with avrdude and copy and paste the results here please?

A 9 second delay sounds suspiciously like you have the "divide by 8" fuse set (for the clock).

Here is what I got from avrdude. The results where in a bin file.

Command : avrdude -c avrispmkII -p m2560 -P usb -U efuse:r:ext:r
Result : 0xFD

Command : avrdude -c avrispmkII -p m2560 -P usb -U hfuse:r:high:r
Result : 0xD8

Command : avrdude -c avrispmkII -p m2560 -P usb -U lfuse:r:low:r
Result : 0xFF

Any hint ?

Thank you for your help !

I don't know avrdude a lot, but I think this information may be more useful. Using the command : avrdude -c avrispmkII -p m2560 -P usb -v

I got :

-----------------Begin-----------------

avrdude: Version 5.11, compiled on Sep 2 2011 at 19:38:36
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"

Using Port : usb
Using Programmer : avrispmkII
avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200012345
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 90 00 0x00 0x00
flash 65 10 256 0 yes 262144 256 1024 4500 45 00 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 90 00 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 90 00 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 90 00 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 90 00 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 : STK500V2
Description : Atmel AVR ISP mkII
Programmer Model: AVRISP mkII
Hardware Version: 0
Firmware Version Master : 1.17
Vtarget : 3.3 V
SCK period : 8.00 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e9801
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D8
avrdude: safemode: efuse reads as FD

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D8
avrdude: safemode: efuse reads as FD
avrdude: safemode: Fuses OK

avrdude done. Thank you.

-----------------End-----------------

Hopping this may be helpful !

The fuses look OK.

I just tried my Mega2560 with the ASCII table example. Re-opening the serial monitor resets the program, but it seems to start instantly.

There is something wrong with your hardware, I suggest. Noise (or lack of pull-up resistors) between the Atmega16U2 and the Atmega2560, or maybe the wrong crystal, or it isn't oscillating correctly. Also make sure you have decoupling capacitors.

I checked both crystal using my oscilloscope, everything appears to be normal. I used the same crystal with the same resistor as the Arduino board (CSTCE16M0V53-R0 16MHZ (built-in capacitor) with 1M ohm resistor). The blink program makes the LED blink at the exact timing (1000 ms on, 1000 ms off).

I tried to program the 16U2 using the hex file on my Uno and its fuses settings, no improvement. Always exactly 9,5 seconds (within the precision of me using a chronograph !).

I may have missed something... If someone has an idea, I'm listening :slight_smile:

I would try two things in your shoes.

  1. Change the fuse to enable clock output. Then put a scope or logic analyzer on the clock output pin.

  2. Put a scope or logic analyzer on the main Tx/Rx pins and see if there is activity on them during those 9 seconds.

Thank Nick for your help, it's greatly appreciated.

  1. I tried the CKOUT Fuse and watch the CLKO with my oscilloscope. Everything is normal, the clock is constant and always working. No problem there.

  2. There is absolutely no activity on either Rx/Tx pins except what I described before (which is happening in the firsts 15 ms).

gabidanpremier:

  1. I tried the CKOUT Fuse and watch the CLKO with my oscilloscope. Everything is normal, the clock is constant and always working. No problem there.

At 16 MHz?

Yes, 16,03 MHz (62.4 ns period).

Can you run my sketch here please, and copy and paste the output? (in code tags)

I can do that !

130128-Output-Atmega_Board_Detector.txt (29.8 KB)

You seem to have this bootloader, based on the MD5 sum:

stk500v2

stk500boot_v2_mega2560.hex
23d339e0ba55f179dd02e0e29d736991 *stk500boot_v2_mega2560.hex
Loader start: 3E000, length: 8192
MD5 sum = 1E 35 14 08 1F 65 7F 8C 96 50 69 9F 19 1E 3D F0 
Board name in IDE: Arduino Mega 2560 or Mega ADK

Could you install this newer one?

// File =  stk500boot_v2_mega2560_fixes_watchdog_problem.hex
// Loader start: 3E000, length: 8192
// MD5 sum = 8A F4 7A 29 43 A0 D8 7C DB ED 09 A3 8F 40 24 1E 
// https://github.com/arduino/Arduino-stk500v2-bootloader/blob/master/goodHexFiles/stk500boot_v2_mega2560.hex

But, when I open the serial monitor, the chip resets and the program starts 9.5 seconds later. Is this delay normal ?

How do you know this anyway? Can you post the code for the sketch you are running?

You're right, I didn't install the one you asked me before sending the text file. For now, I installed this one :

The result is attached with this post.

For the 9,5 seconds, I first remarked it using « SerialCallResponse ». There was a 9,5 seconds between the opening of the serial monitor and the start of the program (and the reception of the first character). Now, I'm just using « Blink » since I can just watch the L LED (pin 13). If I plug the USB cable (or any other power source), the LED starts blinking right away, but when I start the serial monitor there's this 9,5 seconds delay.

130128v2-Output-Atmega_Board_Detector.txt (29.8 KB)

What if you upload something like the ASCII code chart sketch. Test it. Then hit reset on the board and see if the sketch does its stuff again instantly.

gabidanpremier:
I built a standalone Mega2560 board with the Atmega16U2 to be able to use my system as closest as possible to a real Arduino.

Can you describe or draw exactly what you have connected to the reset pin, in particular in the way it connects to the USB chip (and indeed any wiring to it at all)?

I'm sending a part of my circuit schematic. It's almost exactly the same as of the Arduino Mega2560.

I tried something. I used SerialCallResponseASCII. I programmed it and opened the serial monitor. Within the delay (9,5 seconds), I've reset the chip by pulling the reset pin on my 3x2 headers to ground. The programmed started right away and the serial monitor began to show me data, as expected.

So I think there's a link between the request for a reset from the 16U2 and the 9,5 seconds delay.

Put your scope on the reset line. Then open the serial monitor. Watch how long reset is held low.