IAR ITM机制调试信息打印

打印调试信息几种途径:

1.串口打印:

将fputc映射到UART,通过USB-TLL转接板打印调试信息。

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仿真器打印:

cortex-M3内核支持ITM机制,可以通过Jlink打印调试信息。 ITM相关函数在core_cm3.h中有定义,需要将fputc重新映射到ITM,实现printf。

注意:

ITM需要使用SWD的仿真口(且需要连接SWO),而不是常用的Jlink仿真口。

需要激活ITM的Port0端口来捕获信息

时钟需要配置和开发板的时钟一致

 

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

 

   配置ITM的Prot0端口 和 时钟, SWO变绿说明,SWO正常使用

 

  

   仿真:

   将数据逻辑断点打在randomvalue变量处,使用Timeline窗口查看randomvalue。 打印随机数变量 randomvalue到Terminal IO窗口,

   后续使用NIST的STS来验证随机数是否符合标准

   

    

   

 

 

转载于:https://my.oschina.net/Jr413/blog/375294

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值