cancel
Showing results for 
Search instead for 
Did you mean: 

SWV ITM Breaks Debugger

NSmit.9
Associate II

We have a new design using the STM32G474 and are having some weird issues with the SWV utility. Current setup:

  • STM32Cube IDE
  • ST-Link V2-ISOL Debugger using SWCLK, SWDIO, and SWO
  • SWD connection to micro with 33 ohm termination resistors
  • SWO was wired manually using a jumper wire and a 33 ohm resistor (not on original schematic)
  • SWV enabled in IDE
    • Enabled Trace Asynchronous SW in IOC file
    • Using 144 MHz as Core clock in debug config for SWV and in the SysClock on IOC
    • Enabled ITM Port 0
    • Overrode __io_putchar in main

Here’s what we are seeing:

  1. Printf works and outputs under MOST circumstances, skips initial character for some reason
  2. Pausing execution and resuming no longer works
  3. Setting breakpoints during execution no longer works
  4. Resetting the micro using the debugger reset no longer works
  5. Disabling the ITM Port 0 and stopping the trace seems to recover the debug functions above
    1. SWV is still enabled in the configuration and IOC file
    2. Printf is still called but the ITM_PutChar is commented out

1 REPLY 1
NSmit.9
Associate II

Fixed based on recommendations from ST Team. Changed the printf override to this function:

int _write(int file, char *ptr, int len)
{
 int DataIdx;
 
 for(DataIdx=0; DataIdx<len; DataIdx++)
 {
   ITM_SendChar(*ptr++);
 }
 return len;
}

This fixed the above issues with all the previous settings and did not skip the first printed character.

Other recommendations from the ST team for completeness: 

Can you remove the 33ohm resistors? Maybe the resistors with the cable could be generating a filter.

Another option could be using the option limit SWO Clock? (maybe start with 500) By default it is not checked (so it uses auto detect).