This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Simulator issue with printf?

While using the simulator, the values of i in the serial window are shifted by left 8 bits.

#include "stdlib.h"
#include "stdio.h"
#include "reg51.h"

void main (void)
{
    unsigned char i;
    SCON  = 0x50;
    TMOD |= 0x20;
    TH1   = 221;
    TR1   = 1;
    TI    = 1;

    for (i = 0; i < 8; i++)
    {
        printf("%x\n", i);
    }
}

Parents Reply Children
  • "DOES ANYONE KNOW THE ANSWER?"

    Yes, I'm pretty sure we all do. Microsoft probably isn't the place to search. Have you actually typed the three characters 'B', 'C', and 'D' into Google's search text entry box?

  • "I TRY GOOGLE AND MICROSOFT BUT CANNOT FIND ANY CODE THAT WORKS"

    Hmmm ...

    Not sure about Google code, but I have sometimes found myself wondering if Microsoft code works!

    Oh yes ... a hint to the screamer

    I think you mean packed BCD - Try a search for that!

  • "I HAVE GOT 2 HOURS LEFT TO DO THIS"

    A pity -- time is running out. But look at it this way, after time has run out and you fail, you'll have time to reflect on this experience, reread posts, and realize "If I hadn't solicited all those wasted replies simply on the topic of SHOUTING, I might have gotten a legitimate reply on my topic exactly or have been given guidance on how to use Google to effectively search for solutions to my problem. Dang it, I only I had listened and acted accordingly..."