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
  • I wonder why the text "what is bcd" is such a good search term to google on. Might it be because it tells exactly what BCD numbers are, and how they are stored, and how to convert back from BCD to either a binary number or a decimal number?

    Did you get your code from a friend in the same class?

    Are you expecting to send in the same solution?

    Do you think your teacher likes to see two identical solutions?

    Is your friend spending his time on another forum?

    Doesn't it feel good after having really spent some time solving a problem?

Reply
  • I wonder why the text "what is bcd" is such a good search term to google on. Might it be because it tells exactly what BCD numbers are, and how they are stored, and how to convert back from BCD to either a binary number or a decimal number?

    Did you get your code from a friend in the same class?

    Are you expecting to send in the same solution?

    Do you think your teacher likes to see two identical solutions?

    Is your friend spending his time on another forum?

    Doesn't it feel good after having really spent some time solving a problem?

Children