SWO on a Blackpill board

39 Views Asked by At

I've been trying to use SWO on a STM32F411CE based board with no luck at all, when I click debug nothing happens on the ITM console and can't find any tutorial or source on how to properly configure that, any advice? I'm new to the STM tools and Microcontrollers in general

I was using STM32CubeIDE to try a simple helloworld sketch through printf, but when debug session starts nothing happens and no message is shown, its suposed to print hello world on the ITM console, this is my main.c

EDIT:

I was trying to print a hello world using the ITM console, this is the code i have on my main.c:

#include <stdint.h>

#include <stdio.h>

int main(void)
{
    printf("Hello World!");
    for(;;);
} 

All I did was to add the ITM_SendChar function to the syscalls.c:

void ITM_SendChar(uint8_t ch)
{

    //Enable TRCENA
    DEMCR |= ( 1 << 24);

    //enable stimulus port 0
    ITM_TRACE_EN |= ( 1 << 0);

    // read FIFO status in bit [0]:
    while(!(ITM_STIMULUS_PORT0 & 1));

    //Write to ITM stimulus port0
    ITM_STIMULUS_PORT0 = ch;
}

Then, modified the __write function to call the one above:

__attribute__((weak)) int _write(int file, char *ptr, int len)
{
  (void)file;
  int DataIdx;

  for (DataIdx = 0; DataIdx < len; DataIdx++)
  {
    //__io_putchar(*ptr++);

      ITM_SendChar(*ptr++);
  }
  return len;
}

I don't know what I did wrong or if I have to enable/modify something else

0

There are 0 best solutions below