This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADC Output to Char

Hello,

I am trying to read in a voltage from the ADC, convert it to a readable number, and display it on a simply LCD display. The LCD uses SPI communication and will display any type char data sent to it. I thought this sounded pretty straight forward when I started (for many of you it might be, but my C coding is a little rusty). My issue is I can't seem to convert the data from the ADC (or anything for that matter) to type char. I thought I would just use fprintf , but I receive an an error when I try to compile it using IAR EW. It seems I there isn't enough memory. Does anyone have any suggestions for another way of doing the same function as fprintf?

  • Doug Cosby said:
    I thought I would just use fprintf

    well, fprintf prints to a file stream. MSPs do not have an OS and therefore no files and no streams. (stdout is a stream too). So you should either use printf (which requires you to write a putchar function which receives the individual letters and does with them what youo want - there is no default 'console' where to put it), or you use sprintf to print it as a string (0-terminated) into a memory location (an unsigned char array or so).

    However, you already discovered that printf and its brothers are quite large.
    One way is to limit the printf support (project settings) to not support the full bandwidth of valu types, or you write your won conversion function.

    If you use the forum search, you'll find a thread in which a complete conversion function for integer values is discussed and posted.

**Attention** This is a public forum