您好,登錄后才能下訂單哦!
這篇文章將為大家詳細(xì)講解有關(guān)IAR ITM機(jī)制中打印調(diào)試信息的途徑有哪些,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
打印調(diào)試信息幾種途徑:
1.串口打?。?/strong>
將fputc映射到UART,通過USB-TLL轉(zhuǎn)接板打印調(diào)試信息。
STM32F103官方提供的代碼:
/** * @brief Retargets the C library printf function to the USART. * @param None * @retval None */ PUTCHAR_PROTOTYPE { /* Place your implementation of fputc here */ /* e.g. write a character to the USART */ USART_SendData(EVAL_COM1, (uint8_t) ch); /* Loop until the end of transmission */ while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET) { } return ch; }
1.通過Jlink仿真器打?。?/strong>
cortex-M3內(nèi)核支持ITM機(jī)制,可以通過Jlink打印調(diào)試信息。 ITM相關(guān)函數(shù)在core_cm3.h中有定義,需要將fputc重新映射到ITM,實(shí)現(xiàn)printf。
注意:
ITM需要使用SWD的仿真口(且需要連接SWO),而不是常用的Jlink仿真口。
需要激活I(lǐng)TM的Port0端口來捕獲信息
時(shí)鐘需要配置和開發(fā)板的時(shí)鐘一致
SWD接口如下:
fputc映射代碼如下:
/** * @brief Retargets the C library printf function to the USART. * @param None * @retval None */ PUTCHAR_PROTOTYPE { #ifdef DEBUG_USART1 /* Place your implementation of fputc here */ /* e.g. write a character to the USART */ USART_SendData(USART1, (uint8_t) ch); /* Loop until the end of transmission */ while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) { __NOP(); } return ch; #endif #ifdef DEBUG_ITM /* Place your implementation of fputc here */ /* e.g. write a character to the ITM */ ITM_SendChar((uint32_t)ch); return ch; #endif }
IAR配置如下:
使用SWD
仿真:
將數(shù)據(jù)邏輯斷點(diǎn)打在randomvalue變量處,使用Timeline窗口查看randomvalue。 打印隨機(jī)數(shù)變量 randomvalue到Terminal IO窗口,
關(guān)于“IAR ITM機(jī)制中打印調(diào)試信息的途徑有哪些”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。