Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12410 Discussions

alt_printf() not working properly

Altera_Forum
Honored Contributor II
1,987 Views

Hi, I have a problem with the alt_printf() function on my Altera Cyclone IV EP4CE22E22 and Nios II. I got jtaguart as stdout, I've done a simple code like this: 

# include "sys/alt_stdio.h" 

int main() 

char a=0x44; 

alt_printf("A=%x;",a); 

while(1); 

return 0; 

 

and as a result I obtain: 

 

A=; 

 

without any number, 

 

what can I do?
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
834 Views

alt_printf %x is looking for an unsigned int instead of a char. I'm wondering if that is the issue? 

 

Pete
Altera_Forum
Honored Contributor II
834 Views

No, the 'char' value is promoted to 'int' before being passed as an argument. 

I think alt_printf() is a cut down version, check which conversions it supports.
Altera_Forum
Honored Contributor II
834 Views

alt_printf() supports only format specifiers like %c, %s, %x, and %%. 

 

You can see delailed information about it here http://www.altera.com/literature/hb/nios2/n2sw_nii5v2.pdf.
Altera_Forum
Honored Contributor II
834 Views

I recompiled the project without changing anything and now it works properly, very very strange... 

However, if I'd like to print decimal numbers how could I do with this lightweight libraries?
Altera_Forum
Honored Contributor II
834 Views

Write your own function to convert the values to decimal, it isn't hard. 

You should even be able to do it without using any divides.
Reply