Hi Greg.
Your attachment includes part of the source code but not project, so I can't test it.
You mentioned you experienced debugging problem with SOPT1 register.
One possible reason is that SOPT1 register includes STOPE bit which is to enable stop mode. while stop mode is enabled, we can not debug code normally.
Please check this point.
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------