I am a newbie in STM32 and TrueSTUDIO and I would like to ask
for some advice about the using of the SWO's text sending function.
I use the TrueSTUDIO 9.0.0 with ST-LINK (Nucleo-F302R8) and the
target is STM32F102 and seemly the SWO/ITM works corretly, I
see the sent messages in TrueSTUDIO's SWV console, but I
experienced some strange behavior.
1. Sometimes the sent messages are corrupted in the console
window. Some messages are missing or are "overwrited". I tried
different SWO freqs but this does not affect the error.
I use the ITM_SendChar function intensively in an infinite loop
but as I see in the ITM_SendChar's code there is a mechanism
which hangs up the execution until the ITM's fifo available again
and pervents overflow or I think it should be.
What can causes this problem? How can I use the ITM_SendChar
if I would like to get the messages without error?
2. I have a dummy counter in the infinite loop, which is observed
through the SWV Data Trace window which works well but when I
use the my printfx function (which uses the ITM_SendChar) in the
same loop the SWV Data Trace does not work. The value of the I
see only dummyVariable does not change and there is only one write
access int the history and no more.
When I suspend the program execution I see in the Expressions
window that the dummyVariable was incremented. When I comment
out my printfx function the SWV Data Trace works as expected.
Could anyone explain me what happens here? Or is this normal and
should I accept this behavior?
3. Using the SWV Data Trace to watch variables live is not too
convenient. I read the atollic blog, that the Live expressions
window does not work with ST-LINKv2. It is pretty important funciton
and for example the Keil supports this with the ST-LINK. Is there in
plan to support the Live expressions with ST-LINKv2? Or should we
try with the newerST-LINKv3?
Code: Select all
/* core_cm3.h */
__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)
ITM->PORT[0U].u8 = (uint8_t)ch;
void printfx(char* pText)
if (++itmCouner == 10)
itmCouner = 0;
ITM_SendChar(itmCouner + 0x30);
while (*pText != '\0')
/* Infinite loop */
/* USER CODE BEGIN WHILE */
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
/* USER CODE END 3 */