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
  • "WHAT ELSE CAN BE WRONG?"

    The code in its entirety! Move on to the next candidate code.

    By the way, you originally said you wanted to print a BCD value. To us, that means that the value is already in (packed) BCD and you want to print it as ASCII digits. Why do you even care about binary to BCD conversion?

Reply
  • "WHAT ELSE CAN BE WRONG?"

    The code in its entirety! Move on to the next candidate code.

    By the way, you originally said you wanted to print a BCD value. To us, that means that the value is already in (packed) BCD and you want to print it as ASCII digits. Why do you even care about binary to BCD conversion?

Children
No data