I use ATmega169PV - QFN, with 8MHz external crystal. The micro is intended to operate relays, and I got into problem of spurious reset of AVR when a relay is turned on (relay controls a 40W incandescent).
The relays are in a separate PCB, AVR is in a separate PCB which sits on top of relay PCB.
Natural doubt was AVR is getting reset because of low-going pulse(noise) in reset line due to noise by relay contact operation.
I tried decreasing the pull-up resistor value, increase the cap upto 1u - none worked. I even shorted the reset line directly with Vcc - no success.
Then I separated both the boards by a flat ribbon connector, and kept both the boards about 6 inches apart and repeated the reset-RC tweaking - still no success.
Even wrapped the AVR PCB with a conducting foil, grounded the foil at two ends diagonally (indeed forming a ground plane between the relays and AVR) - no success.
Then wrote a test code which would toggle the relay every 600ms, and AVR at startup would turn on specific LEDs for Watchdog reset, Brown out, Power on reset, External reset or JTAG reset (program would check for all conditions in if and else-if, specifically omitted any else condition)
When I turn on the setup for the first time (turn off-on the AC mains itself), then I get indication that its by Power on Reset (expected). However, as the relay toggles, after some 10 to 20 on-off operation, I get only JTAG reset as the indication (indeed, AVR gets resetted nevertheless).
The JTAG-reset pattern looks curious - for every 4th turn-on of relay, I get the reset. I mean (on-off) (on-off) (on-off) (on - AVR resets indicating JTAG reset) - like this the pattern continuous for about 6 to 8 cycles, and then it becomes random, and after sometime this pattern repeats.
Intriguing, since JTAGEN fuse is disabled, JTD bit is set in proper timing in the code, TMS, TDI and TDO pins are shorted to ground, TCK pin is being used as an AD channel.
Datasheet reveals a single bit 'Reset register' for JTAG puposes and a high on this resister would cause a system reset - however as the TDI pin itself is shorted to ground, I dont expect the 'reset register' can output a logic high at Q.
Any thoughts please?