ITM_SendChar blocks when no debugger attached?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-08-23 12:39 AM
I think ITM_SendChar is freezing my code when I don't have a debugger attached
When I do have an debugger attached, it works, and I can see my messagesBut when I don't, then the code doesn't get past the printingBut the comments for this function says ''It just returns when no debugger is connected that has booked the output.''Is the comment wrong? Is there any way I can detect whether or not a debugger is attached? I don't see any obvious bitflags under the DBG register. #debug #swd #itm #itm- Labels:
-
DEBUG
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-08-23 6:43 AM
I'd be looking at Bit 0 of both SCB_DHCSR and ITM_TER to determine if the interface was up.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-08-23 6:52 AM
This is how I check the ITM before sending data:
// make sure debugger attached and ITM enabled
if( (CoreDebug->DHCSR & 1) != 1 ) return IOB_ERR_BUS; // C_DEBUGEN, debugger not attached?
if( (CoreDebug->DEMCR & (1 <<
24
)) == 0 ) return IOB_ERR_BUSERR; // TRCENA, trace not enabled
if( (ITM->TCR & 0x0001) == 0 ) return IOB_ERR_ALERT; // ITMENA, ITM not enabled
port = addr & 0x1f; // extract port number 0-31
if( (ITM->TER & (0x01 << port)) == 0 ) return IOB_ERR_RANGE; // ITM port not enabled
A JTAG has to be attached, ITM enabled and the specific port enabled. I use ITM with the SWO Viewer for execution tracing, much faster than dumping to a serial port.
Jack Peacock
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-08-23 10:28 AM
Checking C_DEBUGEN worked
I'm using a J-Link EDU with J-Link SWO ViewerI think somebody should patch the ITM_SendChar function that's distributed with the standard library to include this checkThanks!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-08-23 10:52 AM
I think somebody should patch the ITM_SendChar function that's distributed with the standard library to include this check
Perhaps, but I've got a more elegant solution which filters/redirects debug output on a character, string, and retargeting level depending on how I'm attached to the system. You should probably be looking at the debugger attachment at a higher level.
Up vote any posts that you find helpful, it shows what's working..
