I have an AVR JTAGICE MKII which I use to program and emulate Atmega164p software and work nicely almost always. But eventually I get stuck with a problem which I keep overcoming by replacing chips. Here is the situation when this happen:
When programming fuses of a new board, at the beginning, seems to work. But after a few more program sections, let´s say after 3 or 4, I get stuck with the following error message from Atmel Studio:
"Failed to lunch program. Error: A unknown emulator error occurred. Debugger command leaveProgrMode failed."
The status shows which the software is loading and stops always at 95%.
I use JTAG to program. I´m absolutely sure there is no cable problems. Other boards works in the same setup. I re check all fuses with a working board and everything looks the same. I can read and verify the fuses and get no errors. I´m able to modify the fuses and the configuration is retained. If I replace the atmega164p (which sucks having to deal with SMT soldering) fix the problem. Would this be a bad lot of chips or maybe there are more details in programming I´m not aware of?
Any suggestion will be of great help.