I have an ATmega644 connected to another device using the UART. After receiving a few characters on the UART the device resets and/or acts weird. Some examples of this behavior:
- Code before the main loop is executed again but MCUSR is 0 (i.e. no "real" reset)
- Code inside the main loop is executed even though the switches connected to the inputs were not pressed (pullups are configured properly).
- Sometimes the MCU just hangs
- Sometimes ports that were not configured as outputs act as outputs (e.g. LEDs connected to them light up even though the DDR for that port is 0).
The device is using an external 18.432 MHz crystal and the UART is set to 19200 baud. It is powered with 5V; the RX pin is connected to a 3V3 RPi.