STM32F407VET6 DEMCR base address
Good morning,
I'm trying to develop a simple Hello World printf example by writting "Hello World" into the port0 of ITM. There are several tutorials telling that 0xE000EDFCU is the base address to set the bit TRCENA to 1. However, when I try to debug my application using the ST-LINK and the SWV ITM Data Console, the port 0 does not display the message, even if the trace is enabled. Is it 0xE000EDFCU the correct base address? The Reference Manual does not contain any information about it. Thanks in advance.
main.c
#include <stdint.h>
#include <stdio.h>
int main(void)
{
printf("Hello World\n");
for(;;);
}
syscalls.c (lines modified)
//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++)
{
// __io_putchar(*ptr++);
ITM_SendChar(*ptr++);
}
return len;
}
