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: How does printing to debugger affect the chip's behavior?

Part Number: TMS570LS1227
Other Parts Discussed in Thread: SEGGER,

I'm using SEGGER's JLink Pro to debug TMS570LS1227. It's really convenient to have the printf function (provided by run time library rtsv7R4_T_be_v3D16_eabi.lib), which prints message through the debugger to the console in CCS.

But the chip seems not to function well when using printf. The peripheral dependent on TMS570's ECLK pin gives wrong output. The ecap module of TMS570 behaves oddly too. Disabling printf solves the problem. But I still need the chip to print messages when running. So how does printing to debugger affect the chip's behavior? And is there a way to cancel the effect?

  • Hello,

    The printf() makes it easy to write something to the console, or to build a string. But the printf() adds 8~10kbytes to the code size, and it also requires more than 400 bytes of stack. If your application causes a stack overflow, it could be because of printf(). I don't think that printf() affects the ECLK output.

    Can you let us know how you use the printf() in your project? and how does the ECLK and ECAP affected? Thanks

  • Here's the program for testing ECLK pin.

    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){}
        }
    }

    The ECLK pin is measured. When enablePrint=0, the ECLK outputs a stable 26.67MHz clock signal, as is configured in HCG. When enablePrint=1, the ECLK output is not stable. Sometimes it is 26.67MHz and sometimes it falls to 19MHz. The current output of the peripheral chip is exactly like the ECLK. When disabling printf, output is stable. When enabling printf, output is fluctuant.

    I also change waitHere flag to be 1 to exclude the possibility that the peripheral needs periodic SPI communication to function.

    The program for testing 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);
    	}
    }

    If waittime is long enough, the values in the buffer are normal, around 35000. If waittime is 0 and it prints all the time, the buffer consists of half 0, half 1000~4000, few 4294967100, which are all wrong numbers.

  • I tested, printf() doesn't affect the clock frequency of ECLK output. There is no change to my ECLK output (20Mhz) on oscilloscope.

    BTW,  if(enablePrint){printf("%x\n",value)}; should be if(enablePrint){printf("%x\n",value);};