Custom Arduino board beeps and process freezes while I'm uploading firmware to it. Why?

The strangest thing is happening to a standalone Arduino board that I've designed and built. The board (whose schematics are below) has the following features:

1. It has an ATmega328P with a 5V voltage regulator.
2. It controls a scoreboard with several 7-display digits linked through the connectors on the right (JP1 through JP12).
3. It has cursor buttons decoded using a voltage ladder through ANALOG_0 (A0).
4. It has a Real Time Clock to keep time when the board is turned off.
5. It has an RF receiver module.
6. It has a UART header (JP17) so I can program the board using a serial port.
7. It has a speaker attached to digital pin 3 (D3).

I upload firmware to it using a RS232-to-TTL adapter that I've also built (schematics also below) and a Serial-to-USB cable. When programming it, the board behaves much like an Arduino Severino board.

What's strange is that, when I upload the firmware using Arduino IDE 1.03, the process is paused in the middle and then the speaker starts to beep continually. It just sits there waiting for me to do something. When I press reset on the board, the beep stops, the upload continues and the firmware is uploaded successfully to the board.

So, my questions are:

1. What is making the upload process pause?
2. Why is the buzzer beeping when the process pauses?

PS. This is a cross post from the newly created Arduino private beta site, but I thought that the question would be on-topic here, too.

• A bug in the firmware. – Ignacio Vazquez-Abrams Feb 12 '14 at 1:23
• @Ignacio - You mean a bug in the firmware (my sketch) that's already loaded and that I'm trying to replace? Or do you mean the bootloader? I'm pretty sure the same problem would happen if I loaded the blink sketch and repeated the process. In any case, I just can't see how the previous sketch can affect the one I'm trying to load (unless it was using the serial port at the same time as I'm trying to use it for uploading the sketch, which it is not). – Ricardo Feb 12 '14 at 1:29
• I wonder if the problem is cause by the RS232 translator you are using. Have you tried to use a dedicated RS232 chip like max232 to see if it solves the problem? – alexan_e Feb 12 '14 at 8:47
• @alexan_e - That's a good idea! That translator is also used in Arduino Severino (S3V3) and it causes me problems there, too. I have a couple of those MAX232 ICs collecting dust in one of my bins. I'll put one of them to use, just to be sure. – Ricardo Feb 12 '14 at 10:48
• These RS232 level translators using transistors depend on the transmitted signal (Tx, from mcu to PC) to charge the pump capacitor and in general are not very reliable, especially when the balance between incoming and outgoing signal is not similar which may discharge the capacitor. To work properly you want to have more traffic from mcu to PC which I'm sure is not the case when programming the chip. – alexan_e Feb 12 '14 at 11:10

I finally found what was causing the problem: the reset signal from pin 4 (DTR - Data Terminal Ready) on the DB9-Female connector was spiking up to 10V before going to 0V and was triggering high-voltage programming on the ATmega. Below is a scope shot showing the situation:

The yellow trace is DTR signal while the green trace is the RESET signal on the ATmega.

According to Atmel's Atmel AVR042: AVR Hardware Design Considerations application note, one should add an ESD diode between ATmega's RESET and Vcc to prevent the reset signal from triggering high-voltage programming mode, like so:

After adding such a small signal diode (1N4148) like the app note recommended, I got the issue fixed. See below the scope shot taken after the diode was added.

Now the 10V peak is gone.

That was a tricky one!! But I could never find what was wrong without research and the right tools. Money on a scope is money well spent!!