cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32 (SWD) printf not working

MPiul
Associate

I'm new using stm32 microcontrollers, I have been trying to use the printf tracing in my code without success, anything is printed on the console . I can start a debug session, I can place breakpoints on my code, inspect variables and all works as expected but not the printf.

My setup :

0690X000009XhBTQA0.png0690X000009XhBEQA0.png0690X000009XhB9QAK.png0690X000009XhB4QAK.jpg

I have reimplemented the _write method:

int _write(int32_t file, uint8_t *ptr, int32_t len)
 
{
 
/* Implement your write code here, this is used by puts and printf for example */
 
int i=0;
 
for(i=0 ; i<len ; i++)
 
ITM_SendChar((*ptr++));
 
return len;
 
}

and placed a breakpoint on :

I have reimplemented the _write method:
 
int _write(int32_t file, uint8_t *ptr, int32_t len)
{
/* Implement your write code here, this is used by puts and printf for example */
int i=0;
for(i=0 ; i<len ; i++)
ITM_SendChar((*ptr++));
return len;
 
}
and place a breakpoint on :
 
__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);
}
and ITM->PORT[0U].u8 = (uint8_t)ch; is being executed but no printf ouput in console.

and ITM->PORT[0U].u8 = (uint8_t)ch; is being executed but no printf ouput in console.

2 REPLIES 2

Core​ speed correct, really 8 MHz, not 72 MHz?

PB3/SWO pin wired?​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MPiul
Associate

I have tried both speeds, no luck either at 8 and 72Mhz.

PB3 ? I have conected PA14 and PA13