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
  • Shouting isn't going to help you!

    Have you tried thinking about how you might use the available facilities to do this?

    Think about how a BCD value is stored - you could extract each digit, and print it; or you could convert the value to a number, and then just print that...

Reply
  • Shouting isn't going to help you!

    Have you tried thinking about how you might use the available facilities to do this?

    Think about how a BCD value is stored - you could extract each digit, and print it; or you could convert the value to a number, and then just print that...

Children