Forum Discussion
Altera_Forum
Honored Contributor
21 years agoIf you want to insure that you print statements complete before you get to the next code, you can change the way printf works such that it does not use the an interrupt and therefore blocks further execution of the thread until all characters are sent. This is very inefficient. (To do this you likely need to change the run time library function call _write.) You could also implement your own uart output function that doesn't use interrupts.
For this type of environment, debugging with printf's is not the best mechanism. Also, the printf takes significant CPU resources if you are using them as frequently as you imply. Which means that when you remove them or add more, your code is likely to act differently. That is the joy of a multitasking environment. There are some very powerful debugging tools for Nios including trace. Using the trace window will tell you the last X number of instructions so you can investigate what went wrong.