However, the target application does not work correctly with SPI feature during debug run.
This seems to be a known issue:
The problem is that AVR Dragon electrically dominates SPI pins (i.e., SCLK, MOSI, and MISO) during the debug execution. So application in the target device cannot use them as expected.
The workaround is to disconnect these pins from Dragon while debug is running. It’s fine to do so since only Reset, VCC and GND pins are necessary for debugging. However, these pins are still needed for following cases so connection and disconnection need to be done frequently. It’s inconvenient to do so physically.
- get in the debug mode.
- get out from the debug mode.
- program the target device.
So I made a tiny device out of my parts box. It works nicely. The device toggles SPI pins connections. One of six-pin headers should be connected to Dragon and the other should go to the target. The device is powered by the target, so you don’t need an extra power supply.