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.

UCD3138A: execution of printf hangs cpu

Part Number: UCD3138A

hi, I want to redirect output of printf to uart0, the redirection of output was quite straightforward:

int fputc(int ch, FILE *f)
{
 while(Uart0Regs.UARTTXST.bit.TX_RDY == 0) {}
 Uart0Regs.UARTTXBUF.all = ch;

 return ch;
}


but I can print only once... then cpu hangs. When I add printf to the function, also without redirecting fputc, I get warning:
#10247-D creating output section ".sysmem" without a SECTIONS

from now on each use of printf or sprintf hangs cpu, without printf in code sprintf works fine.
I use CCS v10.3 with compiler TI v5.2.9
  • quick walkaround is to use this lightweight printf alternative:

    github.com/.../printf

  • Tomasz, I'm not an expert on file implementation in C, so I can't say what the difference is between printf and sprintf.  I have experience with printf grabbing hundreds of bytes of stack just to do a floating point conversion,  and generally being a memory hog, so we have not included support for it.  That was on CCS for the C2000, not the UCD, but I suspect the UCD is similar.

    If you can get away with sprintf, I'd suggest using it, but check your stack usage.    On the C2000, it was tricky, because it grabbed several hundred bytes, and then just used the ones further away from the top of the stack.  It actually went entirely out of the stack assigned to that level and into another stack, so it was difficult to detect.  

    We used to use UART for debugging before we developed the PMBus memory debugger.  We have quite a collection of functions for putting numbers out directly onto the UART, as well as a string.  I'd strongly suggest using those instead if you can.  They are still left, although not called much, in uart.c in the PFC code online at:

    www.ti.com/.../UCD3138PFCEVM-026.