Electronic – arduino – ATmega64 needs to be reset after Power Up

arduinoavrreset

I am using an ATmega64A for my project with ESP8266 and RFM75. But the ATmega64 hangs on power up and I have to pull reset low to make my code work. I'm using an external 8 MHz crystal.

I have connected all VCC and GND pins properly with 0.1 µF capacitors on each VCC PIN. The RESET pin is pulled high with 10 kΩ resistors and 10 µF capacitors are connected between RESET and GND (I have tried 0.1 µF capacitors as well).

I need a some kind of help to get out of this issue. All comments or suggestion will be appreciated.

EDIT 1:
My Schematic attached here.
ATmega64 Schematic.

I have measured voltage level on RESET PIN on power-on condition.

RESET PIN voltage on power on.
RESET PIN voltage on power on

EDIT 2:
Only LED Blinking Code works well on the same hardware, I have checked so many times by switching the supply ON/OFF. I thing Code have some issues.
I'm trying to figure it out.

EDIT 2:
I have flashed Simple LED blinking code on start up before I start ESP8266 or RFM Initialization. I have a Debug option in my code as well. ATmega64 UART1 is used as Debug Terminal. I have tried flashing LED before Debug Initialization. Led Blinking works like charm!
I have a Function in Debug Terminal to print banner on start up. It prints Date time of compile and reboot causes and a version of code. when I have commented the function , my code started working fine. I have tested many time on different boards by the issue disappear from then. here the function which I have removed.

    static void PrintBanner(void)
{
    unsigned char status = MCUCSR;
    unsigned char moreThanOne = 0;

    printf_P(PSTR(CMD_LINE_MSG_WELCOME));
    printf_P(PSTR("Firmware: v%S [Compiled on "__DATE__" "__TIME__"]\r\nBoot cause: "), PSTR(APP_VERSION));

    if(status & (1 << PORF))
    {
        printf_P(PSTR("Power On"));
        MCUCSR &= ~(1 << PORF);
        moreThanOne = 1;
    }
    if(status & (1 << EXTRF))
    {
        if(moreThanOne)
            printf_P(PSTR(", "));
        printf_P(PSTR("External"));
        MCUCSR &= ~(1 << EXTRF);
        moreThanOne = 1;
    }
    if(status & (1 << BORF))
    {
        if(moreThanOne)
            printf_P(PSTR(", "));
        printf_P(PSTR("Brown-out"));
        MCUCSR &= ~(1 << BORF);
        moreThanOne = 1;
    }
    if(status & (1 << WDRF))
    {
        if(moreThanOne)
            printf_P(PSTR(", "));
        printf_P(PSTR("Watchdog"));
        MCUCSR &= ~(1 << WDRF);
        moreThanOne = 1;
    }
    if(status & (1 << JTRF))
    {
        if(moreThanOne)
            printf_P(PSTR(", "));
        printf_P(PSTR("JTAG"));
        MCUCSR &= ~(1 << JTRF);
        moreThanOne = 1;
    }

    printf_P(PSTR(" Reset.\r\n"));
}

What would be the cause for the RESET issue of the ATmega64 with this piece of code?
Does it because of fetching data from program memory to print over UART?
Still I'm trying to go to root cause for this issue.
If anyone have any idea about this kindly throw some light on it.
Thanks.

Best Answer

Some hints:

  1. AVRs have clock startup delay fuses (SUT1/SUT0 for ATmega64) - check if problem happens at different settings of the startup delay.

  2. Use brownout detection (also a fuse setting).

  3. Try adding a busy-wait loop at the beginning.