Skip to main content
Paul M
Associate II
July 30, 2026
Question

SWV ITM Console is not Enabled...Why Not?

  • July 30, 2026
  • 4 replies
  • 41 views

I had created a Project using STM32Cube MX/IDE (versions 6.17 and 2.1.1 respectively)
in which I had set up the SWV ITM Console as the output of printf().

This was working as expected

Then, I moved the same project to a new machine under STM32Cube MX/IDE (versions 6.18 and 2.20 respectively)
When I’m debugging with my new machine, the SWV ITM Console gets no visible output.
I was able to confirm (with breakpoints) that the function ITM_SendChar() *is* getting called as expected.

However, referring to the source code below:
 

__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch)
{
    if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */
       ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */
    {
        while (ITM->PORT[0U].u32 == 0UL)
        {
            __NOP();
        }
        ITM->PORT[0U].u8 = (uint8_t)ch;
    }
    return (ch);
}

...the breakpoints show that the “if()” statement at the start is failing,
so no characters are being written to the PORT.
(On the previous machine, this was working correctly...the “if ()” statement
  would succeed and the characters would be written)

So, then...I diligently compared my MX and my IDE configurations for the SWV ITM
on both machines, and I CANNOT see any difference in what I’ve set up.
Yet--on the new machine, it seems that the ITM (per the TCR and TER regs)
is NOT enabled!  Whereas, on the original machine it was enabled!

Is there yet-another-esoteric setting (MX or IDE) that I have overlooked?
Any one have some advice that starts with “Don’t forget to...” ?

Thanks!
Paul++

 

4 replies

TDK
July 31, 2026

Is SWV enabled in the relevant debug configuration? What chip?

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
Paul M
Paul MAuthor
Associate II
August 3, 2026

TDK,

Thanks, yes, I did enable that and also set the Clock Speed to match the HCLK in my MX Clock-Config

Paul++

Paul++
Pavel A.
August 1, 2026
  1. In the CubeIDE debugger, be sure to activate the ITM reader when the debugger hits a breakpoint (usually the first one, at main). Since ITM worked for you in previous IDE version, you already did this, so just a reminder.
    1. Try also the ITM viewer in the CubeProgrammer :

       

Paul M
Paul MAuthor
Associate II
August 3, 2026

Pavel,

1)  Yes, I did that.  I noticed that in ITM_SendChar(), the lines:
         if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */
             ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */
       ...is the place where it fails.  The TCR/TER Regs indicate that ITM is
        not enabled & therefor no attempt to send a character to ITM ever actually occurs.
       Further, it seems that my MX-generated code is NOT executing any INIT code
        for the ITM (it neither enables nor disables it during the INIT sequence).
        Is it possible I’m somehow missing executing the INIT/Enable code for ITM?

2) Interesting idea...I will try downloading and using the CubeProgrammer just to
     see if the ITM interface works any better.
     However, based on the “No INIT” insight from (1), above, I don’t have much hope
     changing the monitoring code will matter much when
     no characters are being transmitted in the first place.

Thanks for the ideas…!
Paul++

 

Paul++