SWO是什么
代码怎么写
由于SWO是内核Debug组件的的一部分,所以它的API在头文件Drivers/CMSIS/Include/core_cm3.h
中。
/**
\brief ITM Send Character
\details Transmits a character via the ITM channel 0, and
\li Just returns when no debugger is connected that has booked the output.
\li Is blocking when a debugger is connected, but the previous character sent has not been transmitted.
\param [in] ch Character to transmit.
\returns Character to transmit.
*/
__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)
{
__NOP();
}
ITM->PORT[0U].u8 = (uint8_t)ch;
}
return (ch);
}
工具怎么用
J-Link SWO Viewer
SWO Viewer 是J-Link软件包里的一个小工具,使用起来比较简单
STM32CubeIDE
参考资料
AN4989 STM32 microcontroller debug toolbox
https://www.cxymm.net/article/wangjun_eric/105277707
https://blog.csdn.net/weixin_46623350/article/details/105305426