ITM printf trace
I have a STM32L432 Nucleo-32 board and I'm trying to use ITM printf trace.
I created new project with configuration: "Targeted Project type: Empty" "targeted language: C++". I'm not using HAL libraries.
In the syscalls.c I added following code:
//Debug Exception and Monitor Control Register base address
#define DEMCR *((volatile uint32_t*) 0xE000EDFCU )
/* ITM register addresses */
#define ITM_STIMULUS_PORT0 *((volatile uint32_t*) 0xE0000000 )
#define ITM_TRACE_EN *((volatile uint32_t*) 0xE0000E00 )
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;
}
__attribute__((weak)) int _write(int file, char *ptr, int len)
{
(void)file;
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
ITM_SendChar(*ptr++);
}
return len;
}I didn't make any changes to the Clock and as far as I know the default clock for STM32L432 is 4MHz. Here is the debug and ITM configuration:


I also started recording in ITM Data Console window.
I don't see any traces in the SWV ITM Data Console window. Any ideas why? What am I doing wrong?
