Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
21 years ago

new printf features?

First, some background. I am using MicroC/OS-II and one of my tasks (the start task, if it matters) does the following:

    
for (;;)
{
    OSTimeDly(OS_TICKS_PER_SEC * 2);
    printf("CPU Usage = %d\n", OSCPUUsage);
}

I use this mainly as a sanity check to make sure that something is running. I recently switched to Nios II 1.1. After this, some strange things started happening to my boards. LEDs would light for no reason, switches would be read for no reason. After some investigation, it seems that printf is writing into memory. Were there any changes made to the printf functionality? I am using the jtag uart and all output is directed to the jtag uart. Any ideas?

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    This looks like a stack overflow to me. How large is the stack for this task?

    The standard printf uses a surprisingly large amount of stack space (at least 1.5kB) - ticking the small printf option makes it use less.

    I don't remember there being any deliberate changes to printf, but the compiler was upgraded between 1.0 and 1.1 (and with it the newlib implementation of printf) so that might have increased the stack usage enough to tip your task over the edge.