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.
12420 Discussions

How to read a 16-bit data into string in C code

Altera_Forum
Honored Contributor II
844 Views

I have a 16-bit data that is fed from FPGA in vhdl, The NIos II processor reads the 16-bit data from FPGA and do some processing tasks, where Nios II system is programmed in C code 

 

 

How could I read this 16-bit data in string?  

 

 

printf("%d", 16_bit_data);  

// it shows a decimal value of 15282,  

 

 

What should I do in order to get the result displayed as a string 0011101110110010? 

 

 

Thank you in advance.
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
123 Views

C doesn't support that directly. So, I suggest you write yourself a function to do so. Have a look at the following link - I'm sure it'll point you in the right direction. 

 

http://www.programmingsimplified.com/c/source-code/c-program-convert-decimal-to-binary (http://www.programmingsimplified.com/c/source-code/c-program-convert-decimal-to-binary

 

Cheers, 

Alex
Reply