1.
https://www.strongerhuang.com/categories/printf%E7%B3%BB%E5%88%97%E6%95%99%E7%A8%8B/
黄工的这篇文章相当有用
总结一下。
SWO类似于printf
可以替换一个printf,用起来很方便。
core_m4.h
中
__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch)
{
if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */
((ITM->TER & 2UL ) != 0UL) ) /* ITM Port #0 enabled */
{
while (ITM->PORT[1U].u32 == 0UL)
{
__NOP();
}
ITM->PORT[1U].u8 = (uint8_t)ch;
}
return (ch);
}
#include <stdio.h>
#include "core_cm4.h"
int fputc(int ch, FILE *f)
{
ITM_SendChar(ch);
return ch;
}