Hi dmedc,
So the issue always happen on your own app project, not the SDK project, whether my understanding is correct or not?
Answer your questions:
1. is this something likely to happen often when debugging with CMSIS DAP?
Answer: Please help to check, whether this debugger issue just in your own project, SDK project no issues, right?
In fact, just as I have said, when the project have the running issues, it may cause the chip boot failed from the external flash, the chip will take the external flash code as invalid, then it will cause the debugger issues, that's why you erase the external memory, and it works again, this is the know issue to the debugger, the workaround is to erase the external flash memory.
2. is there something I can do to prevent the code affecting the debugger connection?
Answer: You can debug your code, as you said, it always happen when you run the specific code line, check that code, whether that code have issues or not, if you comment it, still have this issues or not?
3. should I expect same behaviour when debugging with other debuggers through J-TAG?
Answer: RT chip is using the SWD interface in default, if you want to use the JTAG, you need to write the fuse. In fact, to your question, JTAG result should be the same as your SWD debugger.
Wish it helps you!
Best Regards,
Kerry