This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TMS570LS1227:打印到调试器如何影响芯片#39的行为?

Guru**** 2595805 points
Other Parts Discussed in Thread: SEGGER, TMS570LS1227

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/991345/tms570ls1227-how-does-printing-to-debugger-affect-the-chip-s-behavior

器件型号:TMS570LS1227
主题中讨论的其他器件:SEGGER

我正在使用 SEGGER 的 JLink Pro 来调试 TMS570LS1227。 使用 printf 函 数(由运行时库 rtsv7R4_T_be_v3D16_eabi.lib 提供)非常方便、该函数通过调试器将消息打印到 CCS 中的控制台。

但  在使用 printf 时、芯片似乎无法正常工作。 依赖于 TMS570的 ECLK 引脚的外设提供错误的输出。 TMS570的 ECAP 模块的行为也异常。 禁用 printf 可以解决问题。 但我仍需要芯片在运行时打印消息。 那么 、打印到调试器如何影响芯片的行为呢? 是否有方法可以消除这种影响?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    printf()可以轻松地将内容写入控制台或构建字符串。 但 printf() 在代码大小中增加了8~10KB,并且还需要400多字节的栈。  如果您的应用程序导致堆栈溢出,则可能是 由于 printf()引起的。 我认为 printf()不会影响 ECLK 输出。

    您能告诉我们您如何在项目中使用 printf()吗? 以及 ECLK 和 ECAP 如何受到影响? 谢谢

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    这是用于测试 ECLK 引脚的程序。

    void wait(unsigned int t){
        while(t--){}
    }
    int main(){
        int enablePrint=0,waitHere=0;
        unsigned int value;
        while(1){
        	value=AssignCurrentOutputUsingSPI();
        	if(enablePrint){printf("%x\n",value)};
        	wait(time);
        	while(waitHere){}
        }
    }

    ECLK 引脚被测量。 当 enablePrint=0时、ECLK 输出一个稳定的26.67MHz 时钟信号、正如在 HCG 中配置的那样。 当 enablePrint=1时、ECLK 输出不稳定。 有时为26.67MHz、有时降至19MHz。  外设芯片的电流输出与 ECLK 完全一样。 禁用 printf 时、输出是稳定的。 启用 printf 时、输出 会波动。

    我还将 waitHere 标志更改为1、以排除 外设 需要定期 SPI 通信才能运行的可能性。

    测试 ECAP 的程序:

    uint32 Period1;
    void ecapNotification(ecapBASE_t* ecap,uint16 flags){
        Period1=ecap->CAP2-ecap->CAP1;
        if(bufferNotFull){enqueue(Period1);}//use buffer to store the values
    }
    int main(){
    	uint32 waittime=0x2fffff;
        uint32 p1;
    	while(1){
    		p1=Period1;
    		printf("%u,%f\n",p1,8e7f/p1);
    		wait(waittime);
    	}
    }

    如果等待时间足够长、则缓冲区中的值是正常的、大约为35000。 如果等待时间为0并且一直打印、则缓冲区由半个0、半个1000~4000、 少数4294967100组成、这些都是错误的数字。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    经测试、printf()不影响 ECLK 输出的时钟频率。 示波器上的 ECLK 输出(20Mhz)没有变化。

    BTW、  if (enablePrint){printf ("%x\n"、value)};应为  if (enablePrint){printf ("%x\n"、value)