I'm working on STM32H753 (STM32H753I-EVAL2 board) using STM32CubeIDE and I'm trying to setup the ITM.
I've started by enabling SWV in the Debugger setting (of course I selected SWD) with Core Clock 400MHz (my CPU clock) and SWO clock 2MHz.
Then in my code I defined the following macro:
#define ITM_Port(n) (*((volatile unsigned long *)(0xE0000000 + 4*n)))
and call this macro as follows, at the location of my code where I want to get a timestamp.
ITM_Port(20) = 0x10;
Finally, in the debug session, I enable ITM stimulus port number 20 and Timerstamp, and launch the SWV Trace Log.
However I don't understand the output:
If I remove the calls to ITM_Port, the trace is empty...
I checked the registers ITM_TCR and ITM_TER and they look correct. Stimulus port 20 is indeed enabled in TER. In TCR, bits ITMENA, TSENA, SYNCENA and TXENA are set.
I looked at assembly level (that looks correct) and I noticed that the store instruction that is supposed to write 0x10 into ITM_STIM20 has no effect,the register is not modified. Is there something to unlock / enable ?
I also configured the GPIO PB3 with alternate function SWO.
Any idea ?

this threadlink. - Stephen Plyaskin