Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

I have a problem with printf

Altera_Forum
Honored Contributor II
1,683 Views

i use a cyclone the hardware is construct and run already on my prototype  

if i use the instruction printf on debug mode my hardware stop to run and i can't find why have you one idea?
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
615 Views

A little more information about the problem would help. For example, are you running in an OS environment? Are you trying to print from an interrupt. Does any of the print get printed? 

 

 

If you are using the uC/OS-II environment and trying to print, the software buffers are relatively small and when the buffer is full the system waits for the interrupt service routine to fire indicating that more characters can be written to the hardware. Then an event flag is used to signal the task that it is okay to transmit. If this happens in a condition when the OS is not running, from interrupts or when interrupts are locked, or the tasking hasn't started it causes a deadlock. (This happens because the flag and semaphore error codes are not monitored in Altera's UART driver.)
0 Kudos
Altera_Forum
Honored Contributor II
615 Views

Does it only stop working when you try to print? 

 

If you have the following combination, the printf() will become a blocking operation when the output buffer fills, and has nowhere to go..: 

 

1. jtag_uart (defined as STDOUT) 

2. _NO_ system timer (interval timer, defined as the system clock in the IDE) 

3. _NO_ cable connected via the jtag_uart (or no program running on the other end of the cable) 

 

Either add a system timer to your system or, if your printf()s are for debug,# ifdef them out for "release" builds. 

 

That is, of course, if this is what you have done. :-) 

 

Best Regards and Best of Luck! 

 

- slacker
0 Kudos
Altera_Forum
Honored Contributor II
615 Views

When my engineer create and modify my hardware it's running but if I add something with my license on the nios it did not run strange in my hardware i don't have a pin for the cpu enabled and in his hardware there is er one it's just to debug that I use the printf instruction.

0 Kudos
Altera_Forum
Honored Contributor II
615 Views

I have "similar" problems. 

 

I amb writing a program with the Nios SDK, which consists on a bucle, and and interrupt. 

 

The STDIO is a uart, I have system timer, and I have a cable connected. 

 

First, I have no printfs in the bucle, and some in the interrupt (it occurs once a second, with enough time for the traces to process). I receive the interrupt 4 times and it stops (I don't know if the program stops, or only the interrupt). 

 

If I define traces in the main bucle (a "."), when the interrupt fires it hangs (without tracing anything of the interrupt). 

 

If I don't call any printfs, all works OK. 

 

So this seem to show that printfs are smoeway dangerous... why? Should they? 

 

Alex
0 Kudos
Reply