Forum Discussion
Altera_Forum
Honored Contributor
13 years agoNiosII printf() not printing correctly
Hi all,
I have a problem with the printf() commands not printing. If I un-tick the "small C library" option in the HAL, I don't receive any output to the NiosII console, but the program is working correctly when I check it in the debugger. However, if I use the "small C library" option I do receive the output, but the numbers (integers) are printed incorrectly (i.e. 128 is printed as 111, 1024 is printed as 1111, and so on). I have two NiosII processors and each of them has a separate JTAG UART in the Qsys system. Has anyone encountered such a problem? Any idea how to resolve this? Cheers, Isuru14 Replies
- Altera_Forum
Honored Contributor
--- Quote Start --- Might be that the divide operation is failing. Maybe you code is using the divide instructions, but it isn't present in your cpu. But %i isn't a standard format. --- Quote End --- I don't have the divider enabled in the CPU. I'll have it enabled and see if it fixes the issue. Thanks ! :) - Altera_Forum
Honored Contributor
--- Quote Start --- Maybe it is a source of incorrect "value" : memory of integer "K" could be overwritten. "Strings" are located inline or at the end of program section, whereas data are in other section. It is a clue, i am not expert in multi processor. Good luck --- Quote End --- Mmmm, that's an interesting thought. but I checked the values from the debugger and they are correct. Only printf() function outputs the messed up values. I also tried sprintf() to get the integer values converted into a string, and the converted string is still incorrect. Biggest problem is why nothing gets printed when the normal C library is used. - Altera_Forum
Honored Contributor
--- Quote Start --- Are the two processors set to use completely different memory areas for absolutely everything? Otherwise things will go very strangely wrong. Similarly I think the stack crashes into the heap - if they collide things will also be 'strange'. --- Quote End --- The two processors use different memory areas for all the code sections. At the moment each processor has 2MB for instructions and 1MB for data sections. - Altera_Forum
Honored Contributor
Does the JTAG UART need a specific clock frequency to communicate correctly with the host PC? Currently all the components in my system run at 100Mhz.