Menu

printf problem!

kamil51
2007-08-17
2013-03-12
  • kamil51

    kamil51 - 2007-08-17

    I have a problem at the printf() function. I am using AT89C52 chip. and I am sending the data to the serial port. For instance when using the code below,

    unsigned char value1,value2,value3,value4,value5;

    value1=0x01;
    value2=0x02;
    value3=0x05;
    //
    value4=0x1A;
    value5=0x3C;
    //
    printf_tiny ("%x%x%x%x%x",value1,value2,value3,value4,value5);

    and data taking from the serial port(rx/tx) like this:
    1251A3C....
    but, data that I need should be like this:
    0102051A3C....
    I used all printf function but same problem.

    awaiting for your reply

    regards
    kamil

     
    • Frieder Ferlemann

      use "%02x%02x" with the printf function.
      (printf_tiny does not support field width)

       
    • Oliver Sedlacek

      Oliver Sedlacek - 2007-08-17

      Beaten to it! As frief says, printf("%02x%02x", value1, value2); is the answer.

       
    • kamil51

      kamil51 - 2007-08-17

      can I use printf_fast_f() function instead of printf()?

      kamil

       
      • Frieder Ferlemann

        > can I use printf_fast_f() function instead of printf()?

        Do you really need floating point???
        Your code snippet gives no indications for that.

        See section 3.16 about printf in the manual and check which flavour you need.

        Of course:
        http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/lib/printf_fast.c?view=markup
        (or your local copy) would be the authoritative answer.

        I'd also consider to continue using printf_tiny() because it is so cute
        and write an extra function like puthex(); where you need an output format
        that printf_tiny() does not support.

         
    • kamil51

      kamil51 - 2007-08-17

      Dear Frieder ,

      Yes, you are right. I dont need using printf_fast_f() but when I used printf()function I am getting some message!
      >>>>>>>>>>>>>>>>>>>>>>>>
      ?ASlink-Error-Could not get 21 consecutive bytes in internal RAM for area DSEG.
      >>>>>>>>>>>>>>>>>>>>>>>>
      What does it mean?

      kamil

       
    • kamil51

      kamil51 - 2007-08-17

      Does someone know what is the meaning of error below?

      ?ASlink-Error-Could not get 21 consecutive bytes in internal RAM for area DSEG

      this error appear when I used printf() function!!!

      kamil

       
      • Maarten Brock

        Maarten Brock - 2007-08-18

        It means that printf is larger than printf_tiny and you now have run out of data memory.

         

Log in to post a comment.