I'd like to include a check into my run-time code for the JTAG debugger. Is there a register/value I can check?
I want to use this for error handling. i.e. if a developer is there debugging the system, pause the execution so developer can investigate. Otherwise, handle situation as elegantly as possible.
Hi Joe,
not sure about your request. Do you want to know from the application if a debugger is attached/connected? If so, I believe there are JTAG/SWD releated registers which could tell you that.
Erich
Erich,
Yes, that's exactly what I'm after. If you happen to know which bits to check, please let me know. Otherwise, I'll do some digging later and report back.
Basically, I'm trying to create a Penalty Box for the developer. If a debugger is attached, I know a developer is present and I want to the code to get stuck forcing the developer to become aware, and hopefully, fix the problem. If that's not the case, I want error handling to take over.
Hello Joe,
You may try with the approach in the next thread:
Regards!
Jorge Gonzalez
Jorge,
Thanks for the answer. After some digging I also found that the DEMCR (Debug Exception and Monitor Control Register) at address 0xE000EDFC) also has what I need in the lsb (Reset Vector Catch enable for the debugger). I'm not sure I see a clear advantage to using one or the other except I have some concerns the the SRS flag wouldn't indicate a JTAG reset. It may on current Kinetis MCU, but I'm pretty sure that wasn't the case a few years ago when I was developing with a K10 part. I'm pretty sure all debugger resets there triggered the POR reset flag.
Once the firmware has confirmed if the debugger is present, I can accomplish my goal, by executing this line of code that forces the debugger to stop.
__ASM volatile ("BKPT #01");
Oops, just caught my mistake. The title of that article had me thinking SRS, but the actual register was different. I guess either should work. Do you see an advantage to using one over the other?
Okay further follow-up... I tried the DHCSR register, but it didn't appear to work for me. The lsb of that register appeared to be set regardless of whether or not a debug session was active or if the debugger was attached to the device. The lsb in DEMCR seems to be working well. So, I'm going to move forward with that solution.
Hi Joe,
You could select to use FreeMaster tool, which is a Run-Time debugging tool.
More detailed info, please check below link:
FreeMASTER Run-Time Debugging Tool|Freescale
It could support using debugger to run-time monitor internal global varaiable.
Wish it helps.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hui_Ma,
That's certainly an option to look into. However, I'm still holding out for something much simpler using my current tools.